import { Component, OnInit } from '@angular/core'
import { JsonApiService } from 'app/core/api/json-api.service' //http请求配置引入
import { Router, ActivatedRoute } from '@angular/router' //路由引入
import { config } from '../../shared/smartadmin.config'

declare var $: any
declare var echarts: any
declare var Viewer: any
@Component({
  selector: 'sa-faultV2',
  templateUrl: './faultV2.component.html',
  styleUrls: ['./faultV2.component.css', './timeline.css']
})
export class FaultV2Component implements OnInit {
  fromType: any = ''
  tableData = [] //table数据
  totalCount: number = 0 //分页总条数
  curPage: number = 1 //分页当前页
  pageSize: number = 10 //内置的分页每页条数
  searchKey: string = '' //搜索keyword
  btnData: any = []
  resourceAdd: boolean = false
  resourceEdit: boolean = false
  resourceDeleteBatch: boolean = false
  faultTypeName: string = '' //查询故障类型参数
  isPush: any = '' //是否推送
  repairedStatus: any = '' //查询故障状态参数
  selectedCompanyName: string = '' //查询公司参数
  selectedCompanyId: string = '' //查询公司参数
  deviceId: string = '' //查询设备参数
  carNumber: string = '' //查询车牌号码参数
  userList: any = [] //用户数据List
  userName: string = '' //查询用户参数
  userId: string = '' //查询用户id参数
  startTime = '' //查询开始时间参数
  endTime = '' //查询结束时间参数
  dateType: any = '1' //时间类型
  sortType: string = '2' //时间类型
  useTypeL1: string = '' //车辆分类一级
  useTypeL2: string = '' //车辆分类二级
  companyData: any = {} // 和子组件通信的数据
  companyType: string = '1' //厂区分类 1安装厂区 2维修厂区
  faultPhenomenon: any = '' //故障现象
  repairContent: any = '' //维修内容
  allChecked: boolean = false //table全选状态值
  selected: any[] = [] //row选择的数据
  inputCompanyTreeCarData: any = {} //车辆运行状态模块跳转该页面传递过来的参数
  expire: string = '' // 保修到期状态 1 未到期 2已到期
  sensorExpire: string = '' // 传感器保修到期状态 0 未到期 1已到期

  TcarUseList = carTypeListObj.carUseList
  carDeatailUseList = carTypeListObj.carDeatailUseList
  jumpData: any // 跳转页面接收到的数据
  //  initDateRange: any = {}// 时间组件需要渲染的值
  provinceId: string = '' //省份ID
  provinceList: any = [] //省份列表数据

  businessTypeList: any[] = [] //行业类型
  businessType: string = ''

  constructor(private jsonApiService: JsonApiService, private router: Router, private activatedRoute: ActivatedRoute) {
    this.businessTypeList = businessTypeList
    activatedRoute.queryParams.subscribe(queryParams => {
      this.curPage = queryParams.nowPage == undefined ? 1 : queryParams.nowPage
      this.inputCompanyTreeCarData = JSON.parse(common.getCookie('jumpRepairedDeviceList'))
      if (common.getCookie('jumpTo/device-management/fault')) {
        this.jumpData = JSON.parse(common.getCookie('jumpTo/device-management/fault'))
        this.companyData.companyId = this.selectedCompanyId = this.jumpData.companyId
        this.companyData.companyName = this.selectedCompanyName = this.jumpData.companyName
      }
    })
  }
  // 获取省份列表
  getProvinceList() {
    this.jsonApiService.http_get('region/getChinessProvince.html').subscribe(data => {
      if (data.success) {
        this.provinceList = data.data
      }
    })
  }
  ngOnInit() {
    this.initBtn()
    this.initRecordDate()
    this.initAllUser().then(() => {
      this.selectUserName()
    })
    this.getUserList() //推拉取的数据
    this.getProvinceList() //请求省份数据
    if (this.inputParam.length == 0) {
      this.querySensor()
    } // 请求传感器列表接口
    this.reviewDate() // 数据的回显
    if (common.getCookie('jumpTo/device-management/fault')) {
      this.initDate().then(() => {
        $('#datetimepicker3').val(this.jumpData.startTime)
        $('#datetimepicker4').val(this.jumpData.endTime) //当前时间
        this.startTime = $('#datetimepicker3').val()
        this.endTime = $('#datetimepicker4').val()
        this.dateType = '2'
        setTimeout(() => {
          this.load()
        }, 100)
      })
      common.clearCookie('jumpTo/device-management/fault')
    } else if (common.getCookie('jumpRepairedDeviceList')) {
      this.searchKey = this.inputCompanyTreeCarData.carNumber
      // this.repairedStatus = this.inputCompanyTreeCarData.repairedStatus;
      this.dateType = this.inputCompanyTreeCarData.dateType
      $('#datetimepicker3').val(this.inputCompanyTreeCarData.startTime)
      $('#datetimepicker4').val(this.inputCompanyTreeCarData.endTime) //当前时间
      this.startTime = $('#datetimepicker3').val()
      this.endTime = $('#datetimepicker4').val()
      setTimeout(() => {
        this.load()
      }, 550)
      common.clearCookie('jumpRepairedDeviceList')
    }else if(common.getCookie('jumpFromSummaryInfo')){
      // 从信息汇总跳转过来的数据
      const summaryInfoParams = JSON.parse(common.getCookie('jumpFromSummaryInfo'))
      if (summaryInfoParams) {
        this.searchKey = summaryInfoParams.carNumber
        $('#datetimepicker3').val('')
        $('#datetimepicker4').val('') //当前时间
        this.startTime = $('#datetimepicker3').val()
        this.endTime = $('#datetimepicker4').val()
        setTimeout(() => {
          this.load()
        }, 100)
        common.clearCookie('jumpFromSummaryInfo')
      }
    } else {
      this.initDate().then(() => {
        this.load()
      })
    }

    const modal: HTMLElement = document.querySelector('#modal-imgBox')
    const header = document.querySelector('#modal-imgHeader-box')
    header.addEventListener('mousedown', function (e: MouseEvent) {
      //鼠标在对话框内的坐标
      let x = e.pageX - modal.offsetLeft
      let y = e.pageY - modal.offsetTop
      // 鼠标移动时，将鼠标在对话框框中的位置赋值给对话框
      document.addEventListener('mousemove', move)
      function move(e) {
        modal.style.left = e.pageX - x + 'px'
        modal.style.top = e.pageY - y + 'px'
      }
      document.addEventListener('mouseup', function () {
        document.removeEventListener('mousemove', move)
      })
    })
  }
  ngOnDestroy() {
    document.onclick = null
  }
  auditCheck: any = false //默认审核权限
  //权限按钮
  initBtn() {
    this.btnData = JSON.parse(decodeURIComponent(localStorage.getItem('cargpsw_device:recordV2:list')))
    if (!this.btnData) {
      return
    }
    for (let item of this.btnData) {
      if (item.sourceKey === 'recordV2:auditCheck' && item.parentId) {
        this.auditCheck = true
      }
    }
  }
  //请求传感器类型的接口
  querySensor() {
    this.jsonApiService.http('sensorManage/querySensorList.html', '').subscribe(data => {
      if (data.success) {
        this.inputParam = data.data
      }
    })
  }
  inputParam: any = []
  //初始化时间
  initDate() {
    var that = this
    return new Promise(function (resolve, reject) {
      System.import('assets/js/datepicker/js/bootstrap-datetimepicker.min.js').then(() => {
        System.import('assets/js/datepicker/locales/bootstrap-datetimepicker.zh-CN.js').then(() => {
          $('#datetimepicker3')
            .datetimepicker({
              format: 'yyyy-mm-dd hh:ii:ss',
              language: 'zh-CN',
              autoclose: true
            })
            .on('changeDate', function (e) {
              var date = e.date
              var time = common.getTimeMmss(date)
              that.startTime = time
              $('#datetimepicker4').datetimepicker('setStartDate', time)
            })
          $('#datetimepicker4')
            .datetimepicker({
              format: 'yyyy-mm-dd hh:ii:ss',
              language: 'zh-CN',
              autoclose: true
            })
            .on('changeDate', function (e) {
              var date = e.date
              var time = common.getTimeMmss(date)
              that.endTime = time
              $('#datetimepicker3').datetimepicker('setEndDate', time)
            })
          var date = new Date()
          let time1 = common.getTimeMmss(date)
          $('#datetimepicker4').val(time1) //当前时间
          that.endTime = time1
          date.setDate(date.getDate() - 31) //设置前31天
          let time2 = common.getTimeMmss(date)
          $('#datetimepicker3').val(time2)
          that.startTime = time2

          //不良记录的时间
          $('#returnTime')
            .datetimepicker({
              //时间插件
              format: 'yyyy-mm-dd hh:ii:ss',
              language: 'zh-CN',
              autoclose: true
            })
            .on('changeDate', function (e) {
              var date = e.date
              if (!date) {
                return
              }
              var time = common.getTimeMmss(date)
              that.recordDetailFrom.returnTime = time
            })

          // $("#returnTime").datetimepicker("setEndDate", date);

          $('#productTime')
            .datetimepicker({
              //时间插件
              format: 'yyyy-mm-dd hh:ii:ss',
              language: 'zh-CN',
              autoclose: true
            })
            .on('changeDate', function (e) {
              var date = e.date
              if (!date) {
                return
              }
              var time = common.getTimeMmss(date)
              that.recordDetailFrom.productTime = time
            })

          $('#resolutionTime')
            .datetimepicker({
              //时间插件
              format: 'yyyy-mm-dd hh:ii:ss',
              language: 'zh-CN',
              autoclose: true
            })
            .on('changeDate', function (e) {
              var date = e.date
              if (!date) {
                return
              }
              var time = common.getTimeMmss(date)
              that.recordDetailFrom.resolutionTime = time
            })
          resolve()
        })
      })
    })
  }
  // 数据的回显
  reviewDate() {
    // 判断是否需要回显
    var deviceFaultDataString = sessionStorage.getItem('deviceFaultData')
    if (deviceFaultDataString) {
      var deviceFaultData = JSON.parse(deviceFaultDataString)
      this.companyData = deviceFaultData
      this.selectedCompanyId = deviceFaultData['companyId']
      this.selectedCompanyName = deviceFaultData['companyName']
      this.deviceId = deviceFaultData['deviceId']
      this.carNumber = deviceFaultData['carNumber']
      this.useTypeL2 = deviceFaultData['useTypeL2']
      this.useTypeL1 = deviceFaultData['useTypeL1']
      this.userName = deviceFaultData['userName']
      this.userId = deviceFaultData['userId']
      // this.faultTypeName      = deviceFaultData["faultTypeName"]
      this.isPush = deviceFaultData['isPush']
      // this.repairedStatus     = deviceFaultData["repairedStatus"]
      this.dateType = deviceFaultData['dateType']
      this.sortType = deviceFaultData['sortType']
      this.startTime = deviceFaultData['startTime']
      this.endTime = deviceFaultData['endTime']
      $('#userNameSelect2').val(this.userName).trigger('change')
      $('#datetimepicker3').val(this.startTime)
      $('#datetimepicker4').val(this.endTime)
      sessionStorage.removeItem('deviceFaultData')
    }
  }
  //删除所选时间
  del_date() {
    this.startTime = ''
    this.endTime = ''
    $('#datetimepicker3').val('').change()
    $('#datetimepicker4').val('').change()
    $('#datetimepicker4').datetimepicker('setStartDate', null)
    $('#datetimepicker3').datetimepicker('setEndDate', null)
  }
  //擦除用户所选值
  delUserName() {
    this.userName = ''
    this.userId = ''
    //采用简单粗暴的方法清除;官方推荐的方法失效
    var str = $("<span class='select2-selection__placeholder'>请选择</span>")
    $('#userNameSelect2').val('')
    $('#select2-userNameSelect2-container').empty()
    $('#select2-userNameSelect2-container').attr('title', '')
    $('#select2-userNameSelect2-container').prepend(str)
  }
  //初始化select2 选项
  selectUserName() {
    var that = this
    System.import('script-loader!select2/dist/js/select2.min.js').then(() => {
      System.import('assets/js/select2-zh-CN.js').then(() => {
        $('#userNameSelect2')
          .select2({
            language: 'zh-CN',
            placeholder: '请选择',
            allowClear: true,
            data: this.userList, //为Select添加数据
            templateResult: this.formatRepo
          })
          .on('select2:select', function (e) {
            var data = e.params.data
            that.userName = data.text
            that.userId = data.id
          })
      })
    })
  }
  //select2 格式回调函数
  formatRepo(state) {
    if (!state.id) {
      return state.text
    }
    var $state = $('<span><i class="fa fa-user green"></i>&nbsp;&nbsp;' + state.text + '</span>')
    return $state
  }
  //拉取
  initAllUser() {
    var that = this
    return new Promise(function (resolve, reject) {
      that.jsonApiService.http('user/getAllUserList.html', null).subscribe(data => {
        if (data.success) {
          var userList = data.data
          var selectdata = []
          for (var i = 0; i < userList.length; i++) {
            var obj = {
              id: userList[i].id,
              text: userList[i].name
            }
            selectdata[i] = obj
          }
        }
        that.userList = selectdata
        resolve()
      })
    })
  }
  //table刷新
  refresh() {
    this.load()
  }
  //表格搜索
  table_search() {
    this.curPage = 1
    this.searchKey = common.stringTrim(this.searchKey)
    this.load()
  }
  //初始化加载list数据
  load() {
    this.startTime = $('#datetimepicker3').val()
    this.endTime = $('#datetimepicker4').val()
    let data = {
      pageSize: this.pageSize,
      nowPage: this.curPage,
      parameters: {
        sortType: this.sortType,
        searchKey: this.searchKey,
        companyType: this.companyType,
        companyId: this.selectedCompanyId,
        deviceId: this.deviceId,
        userName: this.userName,
        // type: this.faultTypeName,
        // repairedStatus: this.repairedStatus,
        startDate: this.startTime,
        endDate: this.endTime,
        useTypeL2: this.useTypeL2,
        faultPhenomenon: this.faultPhenomenon,
        repairContent: this.repairContent,
        provinceId: this.provinceId,
        expire: this.expire,
        // sensorExpire: this.sensorExpire,
        businessType: this.businessType // 行业类型
      }
    }
    let reqdata = 'gridPager=' + JSON.stringify(data)
    this.jsonApiService.http('deviceRepairedV2/findDeviceRepairedV2List.html', reqdata).subscribe(result => {
      this.selected = []
      this.tableData = result.exhibitDatas || []
      for (let item of this.tableData) {
        var faultPhenomenonList = item.faultPhenomenonList && this.unique(item.faultPhenomenonList)
        item.faultPhenomenonList = faultPhenomenonList.length > 0 ? faultPhenomenonList.join(',') : ''

        item.repairStatus = false // 维修内容是否有更换主机
        if (item.repairContentList && item.repairContentList.length) {
          item.repairStatus = item.repairContentList.some(ele => ele === '更换主机')
        }

        var repairContentList = item.repairContentList && this.unique(item.repairContentList)
        item.repairContentList = repairContentList.length > 0 ? repairContentList.join(',') : ''

        var repairSubdivideList = item.repairSubdivideList && this.unique(item.repairSubdivideList)
        item.repairSubdivideList = repairSubdivideList.length > 0 ? repairSubdivideList.join(',') : ''

        // item.faultPhenomenonList =  item.faultPhenomenonList && item.faultPhenomenonList.length > 0 ? item.faultPhenomenonList.join(","): '';
        // item.repairContentList =  item.repairContentList && item.repairContentList.length > 0 ? item.repairContentList.join(","): '';
        // item.repairSubdivideList = item.repairSubdivideList && item.repairSubdivideList.length > 0 ? item.repairSubdivideList.join(","): '';
        item.useTypeL2 = this.getUseTypeNameL2(item.useTypeL2)
      }
      this.totalCount = result.recordCount
    })
  }

  unique(arr) {
    return Array.from(new Set(arr))
  }
  repairedDetailPage: any = {}
  // 维修明细查看
  repairedDetail(modal, row) {
    this.repairedDetailPage = row
    modal.show()
  }
  closeRepairedDetail(modal) {
    modal.hide()
  }
  repairedMonkeyDetail: any = {
    repairOrders: []
  }

  // 维修费用明细
  repairedMonkey(modal, row) {
    let reqdata = 'id=' + row.id
    this.jsonApiService.http2('deviceRepairedV2/getDeviceRepairedV2PriceMsg.html', reqdata).subscribe(data => {
      if (data.success) {
        this.repairedMonkeyDetail = data.data || { repairOrders: [] }
      }
    })
    modal.show()
  }
  closeRepairedMonkey(modal) {
    modal.hide()
  }
  // 车辆分类编码转化
  getUseTypeNameL2(key) {
    if (key) {
      return this.carDeatailUseList[key]
    } else {
      return ''
    }
  }
  //分页回调
  paginate(e) {
    this.curPage = e.page + 1
    this.pageSize = e.rows
    this.load()
    this.selected = []
  }
  //公司选中回调
  companySelected(data) {
    this.selectedCompanyId = data.companyId
    this.selectedCompanyName = data.companyName
    this.deviceId = data.deviceId
    this.carNumber = data.carNumber
    this.useTypeL2 = data.useTypeL2
    this.useTypeL1 = data.useTypeL1
  }

  /**
   * 设备维修记录
   */
  isOpenCalendar: boolean = false
  openRepairedRecord(modal) {
    modal.show()
    this.isOpenCalendar = true
  }
  closeRepairedRecord(modal) {
    modal.hide()
    this.isOpenCalendar = false
  }
  /**
   *  echart图
   */
  activeSelected: any
  startTime_chart: string = ''
  endTime_chart: string = ''
  isChartView: boolean = false
  isMapView: boolean = false
  specifyTime: any = {
    startTime: '',
    endTime: ''
  }
  selectedRow: any
  drawTrackArr: any
  //数据查看
  drawAbnormalChart() {
    if (!this.selectedRow) {
      this.jsonApiService.message('先选择需要查看折线图的车辆')
      return
    }
    if (!this.startTime_chart || !this.endTime_chart) {
      this.jsonApiService.message('时间不能为空')
      return
    }
    let timeCheck = common.correctTimeParams(this.startTime_chart, this.endTime_chart, 0)
    if (!timeCheck.status) {
      this.jsonApiService.message(timeCheck.message)
      return
    }
    this.lineParamDeal(this.selectedRow)
  }
  checkAbnormal(row: any) {
    let temStartFixed = common.mmsstoTimestamp(row.repairedTime)
    row.startTime = common.getTimeMmss(new Date(temStartFixed - 1 * 24 * 3600 * 1000))
    row.endTime = common.getTimeMmss(new Date(temStartFixed + 1 * 24 * 3600 * 1000))
    // row对象新增属性
    this.activeSelected = row.id
    this.startTime_chart = row.startTime
    this.endTime_chart = row.endTime
    this.isChartView = true
    this.specifyTime = {
      startTime: this.startTime_chart,
      endTime: this.endTime_chart
    }
    this.lineParamDeal(row)
  }
  runParent(value) {
    this.drawTrackArr = value
  }
  //折线图时间回调事件
  getSelectChartTime(time) {
    this.startTime_chart = time.startTime
    this.endTime_chart = time.endTime
  }
  showMapView(val) {
    this.isMapView = val
  }
  //获取传感器通道参数
  lineParamDeal(row) {
    let reqdata = 'deviceId=' + row.deviceId
    this.jsonApiService.http('realtime/getRealTimeData.html', reqdata).subscribe(result => {
      if (result.success && result.data) {
        let params = {
          deviceId: row.deviceId,
          startTime: this.startTime_chart,
          endTime: this.endTime_chart,
          coefficient: result.data.coef
        }
        this.selectedRow = params
      }
    })
  }
  closeChart() {
    this.isChartView = false
  }
  /**
   * 统计有故障记录,无故障记录,问题分类部分[注:数据统计]
   */
  totleCount: number //按公司统计:统计所有
  repairCount: number //按公司统计:有故障记录
  waitRepairedCount: number //按公司统计:统计无故障记录
  dataAbnormalCarList: any = [] //问题数据[饼图]
  dataAbnormalCarTotalList: any = [] //问题记录List[table]
  dataAbnormalCarTotal: number //问题总数
  dataRepaireTotalList: any = [] //维修记录List[table]
  //关闭问题分类
  closeQuestionSort(modal) {
    modal.hide()
  }
  //问题分类数据处理
  questionSort(modal) {
    if (!this.selectedCompanyId) {
      this.jsonApiService.message('请选择需要查看的公司!')
      return
    }
    modal.show()
    let data = {
      searchKey: this.searchKey,
      companyId: this.selectedCompanyId,
      deviceId: this.deviceId,
      userName: this.userName,
      // type: this.faultTypeName,
      // repairedStatus: this.repairedStatus,
      dateType: this.dateType,
      sortType: this.sortType,
      companyType: this.companyType,
      startDate: this.startTime,
      endDate: this.endTime,
      isPush: this.isPush, //是否推送
      isByAuth: false,
      useTypeL2: this.useTypeL2
    }
    let reqdata = 'param=' + JSON.stringify(data)
    this.jsonApiService.http('deviceRepaired/countRepairedScale.html', reqdata).subscribe(result => {
      let dataRepaired: any = [] //饼图数据
      this.dataRepaireTotalList = []
      this.totleCount = result.data.totleCount //总数
      this.repairCount = result.data.repairCount //有故障记录
      this.waitRepairedCount = this.totleCount - this.repairCount //无故障记录
      dataRepaired.push({ value: result.data.repairCount, name: '有故障记录[车]' })
      dataRepaired.push({ value: this.waitRepairedCount, name: '无故障记录[车]' })
      this.dataRepaireTotalList.push({ value: result.data.repairCount, name: '有故障记录[车]' })
      this.dataRepaireTotalList.push({ value: this.waitRepairedCount, name: '无故障记录[车]' })
      this.dataRepaireTotalList.push({ value: this.totleCount, name: '合计' })
      this.loadPieChart('总车辆', 'repairedPieChart', dataRepaired, this.totleCount)
    })
    this.jsonApiService.http('deviceRepaired/countDataRecord.html', reqdata).subscribe(result => {
      this.dataAbnormalCarList = []
      this.dataAbnormalCarTotalList = []
      this.dataAbnormalCarTotal = 0
      if (result.data && result.success) {
        let temArr: any = result.data
        for (let key in temArr) {
          let obj = {
            value: temArr[key],
            name: key
          }
          this.dataAbnormalCarList.push(obj)
          this.dataAbnormalCarTotalList.push(obj)
          this.dataAbnormalCarTotal += temArr[key]
        }
        this.dataAbnormalCarTotalList.push({
          value: this.dataAbnormalCarTotal,
          name: '合计'
        })
        this.loadPieChart('问题总数', 'questionPieChart', this.dataAbnormalCarList, this.dataAbnormalCarTotal)
      }
    })
  }
  //饼状图,eleId:元素Id,data渲染的数据
  loadPieChart(name, eleId, data, total) {
    var questionPie = echarts.init(document.getElementById(eleId))
    questionPie.clear()
    var that = this
    var scale = 1
    let temArr = []
    for (let item of data) {
      if (item.value) {
        temArr.push(item)
      }
    }
    var echartData = temArr
    if (echartData.length == 0) {
      return
    }
    var rich = {
      yellow: {
        color: '#49dff0',
        fontSize: 18 * scale,
        padding: [5, 4],
        align: 'center'
      },
      total: {
        color: '#49dff0',
        fontSize: 28 * scale,
        align: 'center'
      },
      white: {
        color: '#fff',
        align: 'center',
        fontSize: 14 * scale,
        padding: [5, 4]
      },
      blue: {
        color: '#ffc72b',
        fontSize: 18 * scale,
        padding: [5, 4],
        align: 'center'
      },
      hr: {
        borderColor: '#0b5263',
        width: '100%',
        borderWidth: 1,
        height: 0
      }
    }
    var option = {
      backgroundColor: '#031f2d',
      title: {
        text: name,
        left: 'center',
        top: '53%',
        padding: [24, 0],
        textStyle: {
          color: '#fff',
          fontSize: 18 * scale,
          align: 'center'
        }
      },
      legend: {
        selectedMode: false,
        formatter: '{total|' + total + '}',
        data: [echartData[0].name],
        left: 'center',
        top: 'center',
        icon: 'none',
        align: 'center',
        textStyle: {
          color: '#fff',
          fontSize: 16 * scale,
          rich: rich
        }
      },
      series: [
        {
          name: name,
          type: 'pie',
          radius: ['42%', '50%'],
          hoverAnimation: false,
          color: [
            '#c23531',
            '#2f4554',
            '#61a0a8',
            '#d48265',
            '#91c7ae',
            '#749f83',
            '#ca8622',
            '#bda29a',
            '#6e7074',
            '#546570',
            '#c4ccd3'
          ],
          label: {
            normal: {
              formatter: function (params, ticket, callback) {
                return (
                  '{white|' +
                  params.name +
                  '}{yellow|' +
                  params.value +
                  '}\n{hr|}\n{blue|' +
                  ((+params.value / total) * 100).toFixed(1) +
                  '%}'
                )
              },
              rich: rich
            }
          },
          labelLine: {
            normal: {
              length: 35 * scale,
              length2: 0,
              lineStyle: {
                color: '#0b5263'
              }
            }
          },
          data: echartData
        }
      ]
    }
    questionPie.setOption(option)
    window.onresize = function () {
      if (questionPie) {
        questionPie.resize()
      }
    }
  }

  /**
   * 单行数据选中事件,仅支持单行选中,不支持多选
   */
  singleRowSelected(row, e, index) {
    if (
      e.target.className.includes('checkbox') ||
      e.target.className.includes('checkbox-flag') ||
      e.target.className.includes('checkbox-td') ||
      e.target.className.includes('checkbox-label')
    ) {
      this.rowSelected(row, e, index)
      return
    }
    for (let item of this.tableData) {
      item['isChecked'] = false
    }
    this.selected = []
    row.isChecked = !row.isChecked
    this.selected.push(row)
  }
  //table 全部选中
  allSelected() {
    this.allChecked = !this.allChecked
    if (!this.allChecked) {
      for (let item of this.tableData) {
        item['isChecked'] = false
      }
      this.selected = []
    } else {
      var temArr = []
      for (let item of this.tableData) {
        item['isChecked'] = true
        temArr.push(item.id)
        this.selected.push(item)
      }
      for (let item of this.selected) {
        temArr.push(item.rowId)
      }
    }
  }

  //table复选框数据row选中事件回调:处理选中状态和deviceId
  rowSelected(row, e, index) {
    // this.selected = [];
    // for(let item of this.tableData){
    // 	item['isChecked'] = false;
    // }
    var index = $.inArray(row, this.selected)
    if (index === -1) {
      row.isChecked = true
      this.selected.push(row)
    } else {
      row.isChecked = false
      this.selected.splice(index, 1)
    }
    var temArr = []
    for (let item of this.selected) {
      temArr.push(item.id)
    }
    this.allChecked = this.selected.length === this.pageSize ? true : false //判断是否全选状态
  }

  // 跳转维修明细
  goRepaireDetail(row) {
    let BaseURL = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port
    // 因为车辆的数据量超过 3M 导致 Cookie 存储不了，这里只传需要用到的字段
    var data = {
      id: row.id,
      deviceId: row.deviceId,
      carNumber: row.carNumber
    }
    common.setCookie('repaireDetail', JSON.stringify(data))
    window.open(BaseURL + '#/device-management/repaire-detail')

    // common.setCookie('repaireDetail', JSON.stringify(row));
    // this.router.navigate(['/device-management/repaire-detail']);
  }
  // 新增删除功能 2020-12-15
  deleteRow(row) {
    this.jsonApiService.confirm_message('删除维修记录会同步永久删除维修明细，确认要删除?').then(() => {
      let reqdata = 'id=' + row.id
      this.jsonApiService.http('deviceRepairedV2/delDeviceRepairedV2.html', reqdata).subscribe(data => {
        this.jsonApiService.message(data.message)
        if (data.success) {
          this.load()
        }
      })
    })
  }

  // 数据导出
  exportData() {
    // 导出的
    this.startTime = $('#datetimepicker3').val()
    this.endTime = $('#datetimepicker4').val()
    let data = {
      pageSize: this.pageSize,
      nowPage: this.curPage,
      parameters: {
        sortType: this.sortType,
        searchKey: this.searchKey,
        companyType: this.companyType,
        companyId: this.selectedCompanyId,
        deviceId: this.deviceId,
        userName: this.userName,
        // type: this.faultTypeName,
        // repairedStatus: this.repairedStatus,
        startDate: this.startTime,
        endDate: this.endTime,
        useTypeL2: this.useTypeL2,
        export: '1',
        faultPhenomenon: this.faultPhenomenon,
        repairContent: this.repairContent,
        provinceId: this.provinceId,
        expire: this.expire,
        // sensorExpire: this.sensorExpire,
        businessType: this.businessType // 行业类型
      }
    }
    let timeCheck = common.correctTime(data.parameters, ['sortType', 'export'], ['startDate', 'endDate'])
    if (!timeCheck.status) {
      this.jsonApiService.message(timeCheck.message)
      return
    }
    common.exprotDataFile(data, 'gridPager', config.BaseURL + 'deviceRepairedV2/findDeviceRepairedV2List.html')
  }
  // 维修数据统计
  exportRepairedData() {
    // 导出的
    const startTime = $('#datetimepicker3').val().slice(0, 10)
    const endTime = $('#datetimepicker4').val().slice(0, 10)
    if (!startTime || !endTime) {
      this.jsonApiService.message('请先选择时间')
      return
    }
    if (common.mmsstoTimestamp(startTime) > common.mmsstoTimestamp(endTime)) {
      this.jsonApiService.message('开始时间不能晚于结束时间')
      return
    }
    window.location.href =
      config.BaseURL +
      'deviceRepairedV2/statisticsDeviceRepaired.html?startTime=' +
      startTime +
      '&endTime=' +
      endTime +
      '&businessType=' +
      this.businessType
  }

  // 维修项数据统计
  exportRepairedContentData() {
    const startTime = $('#datetimepicker3').val().slice(0, 10)
    const endTime = $('#datetimepicker4').val().slice(0, 10)
    if (!startTime || !endTime) {
      this.jsonApiService.message('请先选择时间')
      return
    }
    if (common.mmsstoTimestamp(startTime) > common.mmsstoTimestamp(endTime)) {
      this.jsonApiService.message('开始时间不能晚于结束时间')
      return
    }
    window.location.href =
      config.BaseURL +
      `deviceRepairedV2/statisticsRepairContent.html?startTime=${startTime}&endTime=${endTime}&companyType=${this.companyType}&companyId=${this.selectedCompanyId}`
  }


  /*
  统计模块
  */
  //切换
  dataType: any = '1'
  getTabRequestData(value, type) {
    this.modalType = value
    this.dataType = type
    this.searchStatistics() //请求查询接口
  }
  modalType: any = 'Original'
  TabDataselectedCompanyName: any = ''
  TabDataselectedCompanyId: any = ''
  TabDataStartTime: any = ''
  TabDataEndTime: any = ''
  OriginalDataList: any = {}
  hostDataList: any = {}
  beamDataList: any = {}
  verticalBeamDataList: any = {}
  ironPlateDataList: any = {}
  sensorDataList: any = []
  chainDataList: any = {}
  switchDataList: any = {}
  monitorDataList: any = {}
  //统计
  statistics(modal) {
    var that = this
    this.TabDataselectedCompanyName = this.selectedCompanyName
    this.TabDataselectedCompanyId = this.selectedCompanyId

    if (!this.TabDataselectedCompanyId) {
      this.jsonApiService.message('请先选择需要统计的公司')
      return
    }
    $('#myStatisticsTab .s-lis').removeClass('active')
    $('.tab-content .tab-pane').removeClass('active')
    $('#statisticsModal').find('.s-lis').eq(0).addClass('active')
    $('#statisticsModal').find('.tab-pane').eq(0).addClass('active')
    this.modalType = 'Original'
    modal.show()

    this.TabDataStartTime = this.startTime
    this.TabDataEndTime = this.endTime

    this.OriginalDataList = {}
    this.hostDataList = {}
    this.beamDataList = {}
    this.verticalBeamDataList = {}
    this.ironPlateDataList = {}
    this.sensorDataList = []
    this.chainDataList = {}
    this.switchDataList = {}
    this.monitorDataList = {}

    this.searchStatistics() //请求查询接口

    System.import('assets/js/datepicker/js/bootstrap-datetimepicker.min.js').then(() => {
      System.import('assets/js/datepicker/locales/bootstrap-datetimepicker.zh-CN.js').then(() => {
        $('#OriginalStartTime')
          .datetimepicker({
            //时间插件
            format: 'yyyy-mm-dd hh:ii:ss',
            language: 'zh-CN',
            autoclose: true
          })
          .on('changeDate', function (e) {
            var date = e.date
            if (!date) {
              return
            }
            var time = common.getTimeMmss(date)
            $('#OriginalStartTime').val(time).change()
            that.TabDataStartTime = time
          })

        $('#OriginalEndTime')
          .datetimepicker({
            //时间插件
            format: 'yyyy-mm-dd hh:ii:ss',
            language: 'zh-CN',
            autoclose: true
          })
          .on('changeDate', function (e) {
            var date = e.date
            if (!date) {
              return
            }
            var time = common.getTimeMmss(date)
            $('#OriginalEndTime').val(time).change()
            that.TabDataEndTime = time
          })
        // var date = new Date();
        // $("#datetimepicker2").val(that.getTime(date));//当前时间
        // date.setDate(date.getDate() - 7);//设置前一周
        // $("#datetimepicker1").val(that.getTime(date));
      })
    })
  }
  cancelStatistics(modal) {
    modal.hide()
  }
  statisticsCompanySelected(data) {
    this.TabDataselectedCompanyName = data.companyName
    this.TabDataselectedCompanyId = data.companyId
  }
  //查询
  searchStatistics() {
    if (!this.TabDataselectedCompanyId) {
      this.jsonApiService.message('请先选择需要统计的公司')
      return
    }
    var parm = {
      companyId: this.TabDataselectedCompanyId,
      companyName: this.TabDataselectedCompanyName,
      startTime: this.TabDataStartTime,
      endTime: this.TabDataEndTime,
      type: this.dataType
    }
    // type    1:故障统计    2:故障现象统计  3:维修类型统计 4:主机统计  5:GPS故障统计 6:GPS维修统计  7:传感器故障统计 8:传感器维修统计 9:线材维修统计
    this.jsonApiService.http_obj('deviceRepairedV2/statistics.html', parm).subscribe(data => {
      if (data.success) {
        if (this.modalType == 'Original') {
          this.OriginalDataList = data.data
        } else if (this.modalType == 'host') {
          this.hostDataList = data.data
        } else if (this.modalType == 'beam') {
          this.beamDataList = data.data
        } else if (this.modalType == 'verticalBeam') {
          data.data.repairHostsPCT =
            data.data.repairHostsPCT == '0%'
              ? data.data.repairHostsPCT
              : (Number(data.data.repairHostsPCT) * 100).toFixed(2) + '%'
          data.data.gpsRepairHostsPCT =
            data.data.gpsRepairHostsPCT == '0%'
              ? data.data.gpsRepairHostsPCT
              : (Number(data.data.gpsRepairHostsPCT) * 100).toFixed(2) + '%'
          data.data.sensorRepairHostsPCT =
            data.data.sensorRepairHostsPCT == '0%'
              ? data.data.sensorRepairHostsPCT
              : (Number(data.data.sensorRepairHostsPCT) * 100).toFixed(2) + '%'

          if (data.data.repairHostsPCT.indexOf('.00') != -1) {
            data.data.repairHostsPCT = data.data.repairHostsPCT.replace('.00', '')
          }
          if (data.data.gpsRepairHostsPCT.indexOf('.00') != -1) {
            data.data.gpsRepairHostsPCT = data.data.gpsRepairHostsPCT.replace('.00', '')
          }
          if (data.data.sensorRepairHostsPCT.indexOf('.00') != -1) {
            data.data.sensorRepairHostsPCT = data.data.sensorRepairHostsPCT.replace('.00', '')
          }

          this.verticalBeamDataList = data.data
        } else if (this.modalType == 'ironPlate') {
          data.data.occasionalPCT =
            data.data.occasionalPCT == '0%'
              ? data.data.occasionalPCT
              : (Number(data.data.occasionalPCT) * 100).toFixed(2) + '%'
          data.data.occasionalRemovePCT =
            data.data.occasionalRemovePCT == '0%'
              ? data.data.occasionalRemovePCT
              : (Number(data.data.occasionalRemovePCT) * 100).toFixed(2) + '%'
          data.data.occasionalAntennaPCT =
            data.data.occasionalAntennaPCT == '0%'
              ? data.data.occasionalAntennaPCT
              : (Number(data.data.occasionalAntennaPCT) * 100).toFixed(2) + '%'
          data.data.occasionalHostsPCT =
            data.data.occasionalHostsPCT == '0%'
              ? data.data.occasionalHostsPCT
              : (Number(data.data.occasionalHostsPCT) * 100).toFixed(2) + '%'
          data.data.occasionalOtherPCT =
            data.data.occasionalOtherPCT == '0%'
              ? data.data.occasionalOtherPCT
              : (Number(data.data.occasionalOtherPCT) * 100).toFixed(2) + '%'

          if (data.data.occasionalPCT.indexOf('.00') != -1) {
            data.data.occasionalPCT = data.data.occasionalPCT.replace('.00', '')
          }
          if (data.data.occasionalRemovePCT.indexOf('.00') != -1) {
            data.data.occasionalRemovePCT = data.data.occasionalRemovePCT.replace('.00', '')
          }
          if (data.data.occasionalAntennaPCT.indexOf('.00') != -1) {
            data.data.occasionalAntennaPCT = data.data.occasionalAntennaPCT.replace('.00', '')
          }
          if (data.data.occasionalHostsPCT.indexOf('.00') != -1) {
            data.data.occasionalHostsPCT = data.data.occasionalHostsPCT.replace('.00', '')
          }
          if (data.data.occasionalOtherPCT.indexOf('.00') != -1) {
            data.data.occasionalOtherPCT = data.data.occasionalOtherPCT.replace('.00', '')
          }

          data.data.lostPCT =
            data.data.lostPCT == '0%' ? data.data.lostPCT : (Number(data.data.lostPCT) * 100).toFixed(2) + '%'
          data.data.lostRemovePCT =
            data.data.lostRemovePCT == '0%'
              ? data.data.lostRemovePCT
              : (Number(data.data.lostRemovePCT) * 100).toFixed(2) + '%'
          data.data.lostAntennaPCT =
            data.data.lostAntennaPCT == '0%'
              ? data.data.lostAntennaPCT
              : (Number(data.data.lostAntennaPCT) * 100).toFixed(2) + '%'
          data.data.lostHostsPCT =
            data.data.lostHostsPCT == '0%'
              ? data.data.lostHostsPCT
              : (Number(data.data.lostHostsPCT) * 100).toFixed(2) + '%'
          data.data.lostOtherPCT =
            data.data.lostOtherPCT == '0%'
              ? data.data.lostOtherPCT
              : (Number(data.data.lostOtherPCT) * 100).toFixed(2) + '%'

          if (data.data.lostPCT.indexOf('.00') != -1) {
            data.data.lostPCT = data.data.lostPCT.replace('.00', '')
          }
          if (data.data.lostRemovePCT.indexOf('.00') != -1) {
            data.data.lostRemovePCT = data.data.lostRemovePCT.replace('.00', '')
          }
          if (data.data.lostAntennaPCT.indexOf('.00') != -1) {
            data.data.lostAntennaPCT = data.data.lostAntennaPCT.replace('.00', '')
          }
          if (data.data.lostHostsPCT.indexOf('.00') != -1) {
            data.data.lostHostsPCT = data.data.lostHostsPCT.replace('.00', '')
          }
          if (data.data.lostOtherPCT.indexOf('.00') != -1) {
            data.data.lostOtherPCT = data.data.lostOtherPCT.replace('.00', '')
          }

          data.data.flatPCT =
            data.data.flatPCT == '0%' ? data.data.flatPCT : (Number(data.data.flatPCT) * 100).toFixed(2) + '%'
          data.data.flatRemovePCT =
            data.data.flatRemovePCT == '0%'
              ? data.data.flatRemovePCT
              : (Number(data.data.flatRemovePCT) * 100).toFixed(2) + '%'
          data.data.flatAntennaPCT =
            data.data.flatAntennaPCT == '0%'
              ? data.data.flatAntennaPCT
              : (Number(data.data.flatAntennaPCT) * 100).toFixed(2) + '%'
          data.data.flatHostsPCT =
            data.data.flatHostsPCT == '0%'
              ? data.data.flatHostsPCT
              : (Number(data.data.flatHostsPCT) * 100).toFixed(2) + '%'
          data.data.flatOtherPCT =
            data.data.flatOtherPCT == '0%'
              ? data.data.flatOtherPCT
              : (Number(data.data.flatOtherPCT) * 100).toFixed(2) + '%'

          if (data.data.flatPCT.indexOf('.00') != -1) {
            data.data.flatPCT = data.data.flatPCT.replace('.00', '')
          }
          if (data.data.flatRemovePCT.indexOf('.00') != -1) {
            data.data.flatRemovePCT = data.data.flatRemovePCT.replace('.00', '')
          }
          if (data.data.flatAntennaPCT.indexOf('.00') != -1) {
            data.data.flatAntennaPCT = data.data.flatAntennaPCT.replace('.00', '')
          }
          if (data.data.flatHostsPCT.indexOf('.00') != -1) {
            data.data.flatHostsPCT = data.data.flatHostsPCT.replace('.00', '')
          }
          if (data.data.flatOtherPCT.indexOf('.00') != -1) {
            data.data.flatOtherPCT = data.data.flatOtherPCT.replace('.00', '')
          }

          data.data.notGPSPCT =
            data.data.notGPSPCT == '0%' ? data.data.notGPSPCT : (Number(data.data.notGPSPCT) * 100).toFixed(2) + '%'
          data.data.notGPSRemovePCT =
            data.data.notGPSRemovePCT == '0%'
              ? data.data.notGPSRemovePCT
              : (Number(data.data.notGPSRemovePCT) * 100).toFixed(2) + '%'
          data.data.notGPSAntennaPCT =
            data.data.notGPSAntennaPCT == '0%'
              ? data.data.notGPSAntennaPCT
              : (Number(data.data.notGPSAntennaPCT) * 100).toFixed(2) + '%'
          data.data.notGPSHostsPCT =
            data.data.notGPSHostsPCT == '0%'
              ? data.data.notGPSHostsPCT
              : (Number(data.data.notGPSHostsPCT) * 100).toFixed(2) + '%'
          data.data.notGPSOtherPCT =
            data.data.notGPSOtherPCT == '0%'
              ? data.data.notGPSOtherPCT
              : (Number(data.data.notGPSOtherPCT) * 100).toFixed(2) + '%'

          if (data.data.notGPSPCT.indexOf('.00') != -1) {
            data.data.notGPSPCT = data.data.notGPSPCT.replace('.00', '')
          }
          if (data.data.notGPSRemovePCT.indexOf('.00') != -1) {
            data.data.notGPSRemovePCT = data.data.notGPSRemovePCT.replace('.00', '')
          }
          if (data.data.notGPSAntennaPCT.indexOf('.00') != -1) {
            data.data.notGPSAntennaPCT = data.data.notGPSAntennaPCT.replace('.00', '')
          }
          if (data.data.notGPSHostsPCT.indexOf('.00') != -1) {
            data.data.notGPSHostsPCT = data.data.notGPSHostsPCT.replace('.00', '')
          }
          if (data.data.notGPSOtherPCT.indexOf('.00') != -1) {
            data.data.notGPSOtherPCT = data.data.notGPSOtherPCT.replace('.00', '')
          }

          this.ironPlateDataList = data.data
        } else if (this.modalType == 'sensor') {
          var total = {
            name: '总计',
            count: 0,
            pct: '100'
          }
          if (data.data.length > 0) {
            for (let i = 0; i < data.data.length; i++) {
              total.count = total.count + data.data[i].count
              data.data[i].pct =
                data.data[i].pct == '0%' ? data.data[i].pct : (Number(data.data[i].pct) * 100).toFixed(2)
              if (data.data[i].pct.indexOf('.00') != -1) {
                data.data[i].pct = data.data[i].pct.replace('.00', '')
              }
            }
            data.data.push(total)
          }
          this.sensorDataList = data.data
        } else if (this.modalType == 'chain') {
          data.data.sgn52PCT =
            data.data.sgn52PCT == '0%' ? data.data.sgn52PCT : (Number(data.data.sgn52PCT) * 100).toFixed(2) + '%'
          data.data.sgn52WeldPCT =
            data.data.sgn52WeldPCT == '0%'
              ? data.data.sgn52WeldPCT
              : (Number(data.data.sgn52WeldPCT) * 100).toFixed(2) + '%'
          data.data.sgn52SensorPCT =
            data.data.sgn52SensorPCT == '0%'
              ? data.data.sgn52SensorPCT
              : (Number(data.data.sgn52SensorPCT) * 100).toFixed(2) + '%'
          data.data.sgn52HostsPCT =
            data.data.sgn52HostsPCT == '0%'
              ? data.data.sgn52HostsPCT
              : (Number(data.data.sgn52HostsPCT) * 100).toFixed(2) + '%'
          data.data.sgn52OtherPCT =
            data.data.sgn52OtherPCT == '0%'
              ? data.data.sgn52OtherPCT
              : (Number(data.data.sgn52OtherPCT) * 100).toFixed(2) + '%'

          if (data.data.sgn52PCT.indexOf('.00') != -1) {
            data.data.sgn52PCT = data.data.sgn52PCT.replace('.00', '')
          }
          if (data.data.sgn52WeldPCT.indexOf('.00') != -1) {
            data.data.sgn52WeldPCT = data.data.sgn52WeldPCT.replace('.00', '')
          }
          if (data.data.sgn52SensorPCT.indexOf('.00') != -1) {
            data.data.sgn52SensorPCT = data.data.sgn52SensorPCT.replace('.00', '')
          }
          if (data.data.sgn52HostsPCT.indexOf('.00') != -1) {
            data.data.sgn52HostsPCT = data.data.sgn52HostsPCT.replace('.00', '')
          }
          if (data.data.sgn52OtherPCT.indexOf('.00') != -1) {
            data.data.sgn52OtherPCT = data.data.sgn52OtherPCT.replace('.00', '')
          }

          data.data.occasionally52PCT =
            data.data.occasionally52PCT == '0%'
              ? data.data.occasionally52PCT
              : (Number(data.data.occasionally52PCT) * 100).toFixed(2) + '%'
          data.data.occasionally52WeldPCT =
            data.data.occasionally52WeldPCT == '0%'
              ? data.data.occasionally52WeldPCT
              : (Number(data.data.occasionally52WeldPCT) * 100).toFixed(2) + '%'
          data.data.occasionally52SensorPCT =
            data.data.occasionally52SensorPCT == '0%'
              ? data.data.occasionally52SensorPCT
              : (Number(data.data.occasionally52SensorPCT) * 100).toFixed(2) + '%'
          data.data.occasionally52HostsPCT =
            data.data.occasionally52HostsPCT == '0%'
              ? data.data.occasionally52HostsPCT
              : (Number(data.data.occasionally52HostsPCT) * 100).toFixed(2) + '%'
          data.data.occasionally52OtherPCT =
            data.data.occasionally52OtherPCT == '0%'
              ? data.data.occasionally52OtherPCT
              : (Number(data.data.occasionally52OtherPCT) * 100).toFixed(2) + '%'

          if (data.data.occasionally52PCT.indexOf('.00') != -1) {
            data.data.occasionally52PCT = data.data.occasionally52PCT.replace('.00', '')
          }
          if (data.data.occasionally52WeldPCT.indexOf('.00') != -1) {
            data.data.occasionally52WeldPCT = data.data.occasionally52WeldPCT.replace('.00', '')
          }
          if (data.data.occasionally52SensorPCT.indexOf('.00') != -1) {
            data.data.occasionally52SensorPCT = data.data.occasionally52SensorPCT.replace('.00', '')
          }
          if (data.data.occasionally52HostsPCT.indexOf('.00') != -1) {
            data.data.occasionally52HostsPCT = data.data.occasionally52HostsPCT.replace('.00', '')
          }
          if (data.data.occasionally52OtherPCT.indexOf('.00') != -1) {
            data.data.occasionally52OtherPCT = data.data.occasionally52OtherPCT.replace('.00', '')
          }

          data.data.often52PCT =
            data.data.often52PCT == '0%' ? data.data.often52PCT : (Number(data.data.often52PCT) * 100).toFixed(2) + '%'
          data.data.often52WeldPCT =
            data.data.often52WeldPCT == '0%'
              ? data.data.often52WeldPCT
              : (Number(data.data.often52WeldPCT) * 100).toFixed(2) + '%'
          data.data.often52SensorPCT =
            data.data.often52SensorPCT == '0%'
              ? data.data.often52SensorPCT
              : (Number(data.data.often52SensorPCT) * 100).toFixed(2) + '%'
          data.data.often52HostsPCT =
            data.data.often52HostsPCT == '0%'
              ? data.data.often52HostsPCT
              : (Number(data.data.often52HostsPCT) * 100).toFixed(2) + '%'
          data.data.often52OtherPCT =
            data.data.often52OtherPCT == '0%'
              ? data.data.often52OtherPCT
              : (Number(data.data.often52OtherPCT) * 100).toFixed(2) + '%'

          if (data.data.often52PCT.indexOf('.00') != -1) {
            data.data.often52PCT = data.data.often52PCT.replace('.00', '')
          }
          if (data.data.often52WeldPCT.indexOf('.00') != -1) {
            data.data.often52WeldPCT = data.data.often52WeldPCT.replace('.00', '')
          }
          if (data.data.often52SensorPCT.indexOf('.00') != -1) {
            data.data.often52SensorPCT = data.data.often52SensorPCT.replace('.00', '')
          }
          if (data.data.often52HostsPCT.indexOf('.00') != -1) {
            data.data.often52HostsPCT = data.data.often52HostsPCT.replace('.00', '')
          }
          if (data.data.often52OtherPCT.indexOf('.00') != -1) {
            data.data.often52OtherPCT = data.data.often52OtherPCT.replace('.00', '')
          }

          data.data.dapPCT =
            data.data.dapPCT == '0%' ? data.data.dapPCT : (Number(data.data.dapPCT) * 100).toFixed(2) + '%'
          data.data.dapWeldPCT =
            data.data.dapWeldPCT == '0%' ? data.data.dapWeldPCT : (Number(data.data.dapWeldPCT) * 100).toFixed(2) + '%'
          data.data.dapSensorPCT =
            data.data.dapSensorPCT == '0%'
              ? data.data.dapSensorPCT
              : (Number(data.data.dapSensorPCT) * 100).toFixed(2) + '%'
          data.data.dapHostsPCT =
            data.data.dapHostsPCT == '0%'
              ? data.data.dapHostsPCT
              : (Number(data.data.dapHostsPCT) * 100).toFixed(2) + '%'
          data.data.dapOtherPCT =
            data.data.dapOtherPCT == '0%'
              ? data.data.dapOtherPCT
              : (Number(data.data.dapOtherPCT) * 100).toFixed(2) + '%'

          if (data.data.dapPCT.indexOf('.00') != -1) {
            data.data.dapPCT = data.data.dapPCT.replace('.00', '')
          }
          if (data.data.dapWeldPCT.indexOf('.00') != -1) {
            data.data.dapWeldPCT = data.data.dapWeldPCT.replace('.00', '')
          }
          if (data.data.dapSensorPCT.indexOf('.00') != -1) {
            data.data.dapSensorPCT = data.data.dapSensorPCT.replace('.00', '')
          }
          if (data.data.dapHostsPCT.indexOf('.00') != -1) {
            data.data.dapHostsPCT = data.data.dapHostsPCT.replace('.00', '')
          }
          if (data.data.dapOtherPCT.indexOf('.00') != -1) {
            data.data.dapOtherPCT = data.data.dapOtherPCT.replace('.00', '')
          }

          data.data.shapePCT =
            data.data.shapePCT == '0%' ? data.data.shapePCT : (Number(data.data.shapePCT) * 100).toFixed(2) + '%'
          data.data.shapeWeldPCT =
            data.data.shapeWeldPCT == '0%'
              ? data.data.shapeWeldPCT
              : (Number(data.data.shapeWeldPCT) * 100).toFixed(2) + '%'
          data.data.shapeSensorPCT =
            data.data.shapeSensorPCT == '0%'
              ? data.data.shapeSensorPCT
              : (Number(data.data.shapeSensorPCT) * 100).toFixed(2) + '%'
          data.data.shapeHostsPCT =
            data.data.shapeHostsPCT == '0%'
              ? data.data.shapeHostsPCT
              : (Number(data.data.shapeHostsPCT) * 100).toFixed(2) + '%'
          data.data.shapeOtherPCT =
            data.data.shapeOtherPCT == '0%'
              ? data.data.shapeOtherPCT
              : (Number(data.data.shapeOtherPCT) * 100).toFixed(2) + '%'

          if (data.data.shapePCT.indexOf('.00') != -1) {
            data.data.shapePCT = data.data.shapePCT.replace('.00', '')
          }
          if (data.data.shapeWeldPCT.indexOf('.00') != -1) {
            data.data.shapeWeldPCT = data.data.shapeWeldPCT.replace('.00', '')
          }
          if (data.data.shapeSensorPCT.indexOf('.00') != -1) {
            data.data.shapeSensorPCT = data.data.shapeSensorPCT.replace('.00', '')
          }
          if (data.data.shapeHostsPCT.indexOf('.00') != -1) {
            data.data.shapeHostsPCT = data.data.shapeHostsPCT.replace('.00', '')
          }
          if (data.data.shapeOtherPCT.indexOf('.00') != -1) {
            data.data.shapeOtherPCT = data.data.shapeOtherPCT.replace('.00', '')
          }

          data.data.oppositePCT =
            data.data.oppositePCT == '0%'
              ? data.data.oppositePCT
              : (Number(data.data.oppositePCT) * 100).toFixed(2) + '%'
          data.data.oppositeWeldPCT =
            data.data.oppositeWeldPCT == '0%'
              ? data.data.oppositeWeldPCT
              : (Number(data.data.oppositeWeldPCT) * 100).toFixed(2) + '%'
          data.data.oppositeSensorPCT =
            data.data.oppositeSensorPCT == '0%'
              ? data.data.oppositeSensorPCT
              : (Number(data.data.oppositeSensorPCT) * 100).toFixed(2) + '%'
          data.data.oppositeHostsPCT =
            data.data.oppositeHostsPCT == '0%'
              ? data.data.oppositeHostsPCT
              : (Number(data.data.oppositeHostsPCT) * 100).toFixed(2) + '%'
          data.data.oppositeOtherPCT =
            data.data.oppositeOtherPCT == '0%'
              ? data.data.oppositeOtherPCT
              : (Number(data.data.oppositeOtherPCT) * 100).toFixed(2) + '%'

          if (data.data.oppositePCT.indexOf('.00') != -1) {
            data.data.oppositePCT = data.data.oppositePCT.replace('.00', '')
          }
          if (data.data.oppositeWeldPCT.indexOf('.00') != -1) {
            data.data.oppositeWeldPCT = data.data.oppositeWeldPCT.replace('.00', '')
          }
          if (data.data.oppositeSensorPCT.indexOf('.00') != -1) {
            data.data.oppositeSensorPCT = data.data.oppositeSensorPCT.replace('.00', '')
          }
          if (data.data.oppositeHostsPCT.indexOf('.00') != -1) {
            data.data.oppositeHostsPCT = data.data.oppositeHostsPCT.replace('.00', '')
          }
          if (data.data.oppositeOtherPCT.indexOf('.00') != -1) {
            data.data.oppositeOtherPCT = data.data.oppositeOtherPCT.replace('.00', '')
          }

          data.data.flatPCT =
            data.data.flatPCT == '0%' ? data.data.flatPCT : (Number(data.data.flatPCT) * 100).toFixed(2) + '%'
          data.data.flatHostsPCT =
            data.data.flatHostsPCT == '0%'
              ? data.data.flatHostsPCT
              : (Number(data.data.flatHostsPCT) * 100).toFixed(2) + '%'
          data.data.flatSensorPCT =
            data.data.flatSensorPCT == '0%'
              ? data.data.flatSensorPCT
              : (Number(data.data.flatSensorPCT) * 100).toFixed(2) + '%'
          data.data.flatWeldPCT =
            data.data.flatWeldPCT == '0%'
              ? data.data.flatWeldPCT
              : (Number(data.data.flatWeldPCT) * 100).toFixed(2) + '%'
          data.data.flatOtherPCT =
            data.data.flatOtherPCT == '0%'
              ? data.data.flatOtherPCT
              : (Number(data.data.flatOtherPCT) * 100).toFixed(2) + '%'

          if (data.data.flatPCT.indexOf('.00') != -1) {
            data.data.flatPCT = data.data.flatPCT.replace('.00', '')
          }
          if (data.data.flatHostsPCT.indexOf('.00') != -1) {
            data.data.flatHostsPCT = data.data.flatHostsPCT.replace('.00', '')
          }
          if (data.data.flatSensorPCT.indexOf('.00') != -1) {
            data.data.flatSensorPCT = data.data.flatSensorPCT.replace('.00', '')
          }
          if (data.data.flatWeldPCT.indexOf('.00') != -1) {
            data.data.flatWeldPCT = data.data.flatWeldPCT.replace('.00', '')
          }
          if (data.data.flatOtherPCT.indexOf('.00') != -1) {
            data.data.flatOtherPCT = data.data.flatOtherPCT.replace('.00', '')
          }

          data.data.allFlatPCT =
            data.data.allFlatPCT == '0%' ? data.data.allFlatPCT : (Number(data.data.allFlatPCT) * 100).toFixed(2) + '%'
          data.data.allFlatHostsPCT =
            data.data.allFlatHostsPCT == '0%'
              ? data.data.allFlatHostsPCT
              : (Number(data.data.allFlatHostsPCT) * 100).toFixed(2) + '%'
          data.data.allFlatWirePCT =
            data.data.allFlatWirePCT == '0%'
              ? data.data.allFlatWirePCT
              : (Number(data.data.allFlatWirePCT) * 100).toFixed(2) + '%'
          data.data.allFlatOtherPCT =
            data.data.allFlatOtherPCT == '0%'
              ? data.data.allFlatOtherPCT
              : (Number(data.data.allFlatOtherPCT) * 100).toFixed(2) + '%'

          if (data.data.allFlatPCT.indexOf('.00') != -1) {
            data.data.allFlatPCT = data.data.allFlatPCT.replace('.00', '')
          }
          if (data.data.allFlatHostsPCT.indexOf('.00') != -1) {
            data.data.allFlatHostsPCT = data.data.allFlatHostsPCT.replace('.00', '')
          }
          if (data.data.allFlatWirePCT.indexOf('.00') != -1) {
            data.data.allFlatWirePCT = data.data.allFlatWirePCT.replace('.00', '')
          }
          if (data.data.allFlatOtherPCT.indexOf('.00') != -1) {
            data.data.allFlatOtherPCT = data.data.allFlatOtherPCT.replace('.00', '')
          }

          this.chainDataList = data.data
        } else if (this.modalType == 'switch') {
          data.data.repairSensorPCT =
            data.data.repairSensorPCT == '0%'
              ? data.data.repairSensorPCT
              : (Number(data.data.repairSensorPCT) * 100).toFixed(2) + '%'
          data.data.sensorWeldPCT =
            data.data.sensorWeldPCT == '0%'
              ? data.data.sensorWeldPCT
              : (Number(data.data.sensorWeldPCT) * 100).toFixed(2) + '%'
          data.data.sensorRepairHostsPCT =
            data.data.sensorRepairHostsPCT == '0%'
              ? data.data.sensorRepairHostsPCT
              : (Number(data.data.sensorRepairHostsPCT) * 100).toFixed(2) + '%'
          data.data.sensorRepairWirePCT =
            data.data.sensorRepairWirePCT == '0%'
              ? data.data.sensorRepairWirePCT
              : (Number(data.data.sensorRepairWirePCT) * 100).toFixed(2) + '%'

          if (data.data.repairSensorPCT.indexOf('.00') != -1) {
            data.data.repairSensorPCT = data.data.repairSensorPCT.replace('.00', '')
          }
          if (data.data.sensorWeldPCT.indexOf('.00') != -1) {
            data.data.sensorWeldPCT = data.data.sensorWeldPCT.replace('.00', '')
          }
          if (data.data.sensorRepairHostsPCT.indexOf('.00') != -1) {
            data.data.sensorRepairHostsPCT = data.data.sensorRepairHostsPCT.replace('.00', '')
          }
          if (data.data.sensorRepairWirePCT.indexOf('.00') != -1) {
            data.data.sensorRepairWirePCT = data.data.sensorRepairWirePCT.replace('.00', '')
          }

          this.switchDataList = data.data
        } else if (this.modalType == 'monitor') {
          data.data.offLineWireTotalPCT =
            data.data.offLineWireTotalPCT == '0%'
              ? data.data.offLineWireTotalPCT
              : (Number(data.data.offLineWireTotalPCT) * 100).toFixed(2) + '%'
          data.data.sensorWireTotalPCT =
            data.data.sensorWireTotalPCT == '0%'
              ? data.data.sensorWireTotalPCT
              : (Number(data.data.sensorWireTotalPCT) * 100).toFixed(2) + '%'

          if (data.data.offLineWireTotalPCT.indexOf('.00') != -1) {
            data.data.offLineWireTotalPCT = data.data.offLineWireTotalPCT.replace('.00', '')
          }
          if (data.data.sensorWireTotalPCT.indexOf('.00') != -1) {
            data.data.sensorWireTotalPCT = data.data.sensorWireTotalPCT.replace('.00', '')
          }

          data.data.total = data.data.offLineWireTotal + data.data.sensorWireTotal
          this.monitorDataList = data.data
        }
      }
    })
  }

  /**
   * 审核
   */
  status: string = '' //审核状态
  describe: string = '' //审核意见
  statusId: any = ''
  userStatusName: any = ''
  cancelAudit(val) {
    val.hide()
  }
  auditSubmit(type, modal2) {
    var that = this
    if (this.status == '' || this.status == undefined) {
      this.jsonApiService.message('请先选择审核状态')
      return
    }
    if (this.describe == '' && this.status == '2') {
      this.jsonApiService.message('请先输入描述内容')
      return
    }
    if (type == '1' || type == '2') {
      var redata = {
        id: this.statusId,
        status: this.status,
        describe: this.describe,
        operateType: type
      }
      this.jsonApiService.http_obj('deviceRepairedV2/auditRecord.html', redata).subscribe(data => {
        this.jsonApiService.message(data.message)
        this.load()
        setTimeout(function () {
          that.selected = []

          for (let i = 0; i < that.tableData.length; i++) {
            if (that.tableData[i].id == that.statusId) {
              that.tableData[i].isChecked = true
              that.selected.push(that.tableData[i])
            }
          }
        }, 300)

        // val.hide();
      })
    } else {
      this.userStatusName = ''
      $('#userNamePushModal .s_del_icon').click()
      modal2.show()
    }
  }
  /**
   *  推送他人模块
   */
  // 推送他人
  submitUserNamePush(modal) {
    var that = this
    if (this.status == '') {
      this.jsonApiService.message('请先选择审核状态')
      return
    }
    if (this.describe == '' && this.status == '2') {
      this.jsonApiService.message('请先输入描述内容')
      return
    }
    if (this.userStatusName == '' || this.userStatusName == undefined) {
      this.jsonApiService.message('请先选择需要推送的人员')
      return
    }
    var redata = {
      id: this.statusId,
      status: this.status,
      describe: this.describe,
      operateType: '2',
      userName: this.userStatusName
    }
    this.jsonApiService.http_obj('deviceRepairedV2/auditRecord.html', redata).subscribe(data => {
      this.jsonApiService.message(data.message)
      this.load()
      modal.hide()

      setTimeout(function () {
        that.selected = []

        for (let i = 0; i < that.tableData.length; i++) {
          if (that.tableData[i].id == that.statusId) {
            that.tableData[i].isChecked = true
            that.selected.push(that.tableData[i])
          }
        }
      }, 300)
    })
  }
  // 取消推送他人
  cancelUserNamePush(modal) {
    this.userStatusName = ''
    modal.hide()
  }
  userListAll: any
  paramFormat: any = {
    id: 'userName',
    text: 'name'
  }
  // 用户
  getUserList() {
    this.jsonApiService.http('user/getUserList.html', null).subscribe(data => {
      if (data.success) {
        this.userListAll = data.data
      }
    })
  }
  //角色选中
  optionSelectedForm(data) {
    this.userStatusName = data.id
  }

  //审核状态改变
  auditStatusChange(val) {
    this.status = val
    if (val == 1) {
      this.isfirStatus = true
      this.isTwoStatus = false
    } else if (val == 2) {
      this.isfirStatus = false
      this.isTwoStatus = true
    } else {
      this.isfirStatus = false
      this.isTwoStatus = false
    }
  }
  //安装记录审核
  audit_Record(row, val) {
    this.statusId = row.id
    this.describe = ''
    this.status = ''
    this.userStatusName = ''

    val.show()
  }

  /**
   * 图片查看的功能
   */
  imagesInfo: any = [] //图片展示
  isViewer: boolean = false //默认隐藏
  //显示图片组件
  viewer: any = ''
  beforeImageInfo: any = [] //维修前图片展示
  afterImageInfo: any = [] //维修后图片展示
  isfirStatus: boolean = false //审核通过
  isTwoStatus: boolean = false //审核不通过
  //查看照片
  open_img(row, val) {
    this.describe = row.describe
    this.status = row.auditStatus
    this.userStatusName = ''
    this.statusId = row.id
    this.beforeImageInfo = []
    this.afterImageInfo = []

    if (row.auditStatus == 1) {
      this.isfirStatus = true
      this.isTwoStatus = false
    } else if (row.auditStatus == 2) {
      this.isfirStatus = false
      this.isTwoStatus = true
    } else {
      this.isfirStatus = false
      this.isTwoStatus = false
    }

    this.jsonApiService.http_obj('deviceRepairedV2/queryById.html', { id: row.id }).subscribe(data => {
      if (data.success) {
        // 返回的维修后图片列表数据
        this.beforeImageInfo = JSON.parse(JSON.stringify(data.data.beforeImageInfo))
        // 返回的维修前图片列表数据
        this.afterImageInfo = JSON.parse(JSON.stringify(data.data.afterImageInfo))
      } else {
        this.jsonApiService.message(data.message)
      }
    })

    if (this.isViewer && $('.viewer-container').length > 0) {
      this.viewer.destroy()
    }

    val.show()
  }
  //图片放大
  bigimg() {
    // modal.show();
    if (this.isViewer && $('.viewer-container').length > 0) {
      System.import('assets/js/viewer/viewer.js').then(() => {
        System.import('assets/js/viewer/bootstrap.bundle.min.js').then(() => {
          System.import('assets/js/viewer/viewer.css').then(() => {
            this.showImg()
          })
        })
      })
    } else {
      this.showImg()
    }
  }
  showImg() {
    var that = this
    var imgList = $('.imagesInfo')[0]
    this.viewer = new Viewer(imgList, {
      url: 'src',
      title: function (image) {
        return image.alt + ' (' + (this.index + 1) + '/' + this.length + ')'
      }
    })
    that.isViewer = true
  }
  //关闭图片弹窗
  imgClose(val) {
    this.describe = ''
    this.status = ''
    this.userStatusName = ''
    $('#userNamePushModal .s_del_icon').click()
    this.isfirStatus = false
    this.isTwoStatus = false
    val.hide()

    this.selected = []

    for (let i = 0; i < this.tableData.length; i++) {
      if (this.tableData[i].id == this.statusId) {
        this.tableData[i].isChecked = true
        this.selected.push(this.tableData[i])
      }
    }
  }

  /**
   * 设备信息
   *
   *
   *
   *
   *
   */

  /**
   * 设备详细(设备基本信息/故障信息/维修信息/警报信息/数据修复)
   */
  selectRowData: any = {
    companyName: '',
    companyId: '',
    deviceId: '',
    carNumber: ''
  } //选中数据查看的数据row
  deviceDetail() {
    if (this.selected.length == 0) {
      this.jsonApiService.message('请选择要查看的车辆')
      return
    }

    if (this.selected.length > 1) {
      this.jsonApiService.message('请选择要查看的一辆车辆')
      return
    }
    this.selectRowData = this.selected[0]
    $('#deviceDetailModal').show()
    $('.s-lis').removeClass('active')
    $('.tab-pane').removeClass('active')
    $('.s-lis').eq(0).addClass('active')
    $('.s-lis').eq(0).find('a').attr('aria-expanded', 'true')
    $('#all').eq(0).addClass('active')
    this.btnGroupActive = '5'
    let temDate = new Date()
    temDate.setDate(temDate.getDate() - 90) //默认近三个月
    this.startDateBtn = common.getTimeMmss(temDate)
    this.endDateBtn = common.getNowTime()
    this.getDeviceInfoData()
    this.getTableDataTab('7') //渲染磅单表格
  }
  /**
   * 关闭设备详情弹窗
   */
  cancelDeviceDetail() {
    $('#deviceDetailModal').hide()
  }
  tableMove() {
    $('body').delegate('#headDrag', 'mousedown', function (e) {
      $(this).css('cursor', 'move')
      var offset = $('#deviceDetailModal').position()
      var x = e.pageX - offset.left
      var y = e.pageY - offset.top
      $(document).bind('mousemove', function (ev) {
        $('#deviceDetailModal').stop()
        var _x = ev.pageX - x
        var _y = ev.pageY - y
        $('#deviceDetailModal').animate({ left: _x + 'px', top: _y + 'px' }, 2)
      })
    })
    $(document).mouseup(function () {
      //	        $(".hold-all").css("cursor","default");
      $('#deviceDetailModal').css('cursor', 'default')
      $(this).unbind('mousemove')
    })
    //      $('body').delegate('.hold-title','mousedown',function(e){
    //          $(this).css("cursor","move");
    //          var offset = $('.hold-all').position();
    //          var x = e.pageX - offset.left;
    //          var y = e.pageY - offset.top;
    //          console.log(offset.left,'========offset.left=======')
    //          console.log(x,'========xxxx=======')
    //          $(document).bind("mousemove",function(ev){
    //              $(".hold-all").stop();
    //              var _x = ev.pageX - x;
    //              var _y = ev.pageY - y;
    //              $(".hold-all").animate({left:_x+"px",top:_y+"px"},2);
    //          });
    //      });
  }
  /**
   * 获取设备信息 (设备基本信息/故障信息/维修信息/警报信息/数据修复)
   */
  deviceBaseInfo: any = {
    companyName: '',
    carNumber: '',
    deviceId: '',
    hwVersion: '',
    useTypeL1: '',
    useTypeL2: '',
    userTypeName: '',
    sensorType: '',
    productNo: '',
    iccid: '',
    driverName: '',
    phone: '',
    inputDate: '',
    userNameForCreate: '',
    sensorChannel: [],
    coef: [],
    coefT: [],
    version: ''
  }
  questionRecordInfo: any = [] //问题记录
  questionRecordTotal: number = 0 //问题记录总和
  dataFixInfo: any = {} //数据修复
  alertDataInfo: any = {} //警报数据
  repairedDeviceInfo: any = {} //维修记录
  deviceRealTimeDataInfo: any = {} //设备实时数据
  isShowGPSAlert: boolean = false //是否显示GPS数据更新异常警报提示
  isShowOfflineAlert: boolean = false //是否显示离线警报提示
  offlineDiffTime: string = '' //离线时长
  weightCount: number = 0 //过磅次数

  weightData: any = {
    //总磅单数
    WeightBridgeCount: '',
    weight: '',
    lastDate: ''
  }

  initDeviceBaseInfo() {
    this.deviceBaseInfo = {
      companyName: '',
      carNumber: '',
      deviceId: '',
      hwVersion: '',
      useTypeL1: '',
      useTypeL2: '',
      userTypeName: '',
      sensorType: '',
      productNo: '',
      iccid: '',
      driverName: '',
      phone: '',
      inputDate: '',
      userNameForCreate: '',
      sensorChannel: [],
      coef: [],
      coefT: [],
      version: ''
    }
    this.isShowGPSAlert = false
    this.isShowOfflineAlert = false
    this.questionRecordInfo = []
    this.questionRecordTotal = 0
    this.dataFixInfo = {}
    this.alertDataInfo = {}
    this.repairedDeviceInfo = {}
    this.deviceRealTimeDataInfo = {}
    this.offlineDiffTime = ''
    this.weightCount = 0
  }

  /**
   * 设备详细    导航tab切换
   */
  tableDataTab1: any = []
  tableDataTab2: any = []
  tableDataTab2_1: any = []
  tableDataTab3: any = []
  tableDataTab4_1: any = []
  tableDataTab4_2: any = []
  tableDataTab5: any = []
  tableDataTab6: any = []
  tableDataTab7: any = [] //磅单数据
  totalCountTab: number = 0
  pageSizeTab: number = 10
  curPageTab: number = 1 //分页当前页
  activeTab: string = ''
  btnGroupActive: string = '5' //快捷时间按钮(默认三个月);
  btnGroupActiveText: string = '近三个月' //快捷时间按钮文字
  startDateBtn: string = ''
  endDateBtn: string = ''
  /**
   * 时间快捷选择方式:一周/半个月/一个月/两个月/三个月
   */
  selectTimeFast(val) {
    this.btnGroupActive = val
    let temDate = new Date()
    switch (val) {
      case '1':
        this.btnGroupActiveText = '近一周'
        temDate.setDate(temDate.getDate() - 7) //近一周
        this.startDateBtn = common.getTimeMmss(temDate)
        this.endDateBtn = common.getNowTime()
        break
      //			case '2':
      //				this.btnGroupActiveText = '近半个月';
      //				temDate.setDate(temDate.getDate() - 15);//近半个月
      //				this.startDateBtn = common.getTimeMmss(temDate);
      //				this.endDateBtn = common.getNowTime();
      //				break;
      case '3':
        this.btnGroupActiveText = '近一个月'
        temDate.setMonth(temDate.getMonth() - 1) //近一个月
        this.startDateBtn = common.getTimeMmss(temDate)
        this.endDateBtn = common.getNowTime()
        break
      //			case '4':
      //				this.btnGroupActiveText = '近两个月';
      //				temDate.setDate(temDate.getDate() - 60);//近两个月
      //				this.startDateBtn = common.getTimeMmss(temDate);
      //				this.endDateBtn = common.getNowTime();
      //				break;
      case '5':
        this.btnGroupActiveText = '近三个月'
        temDate.setMonth(temDate.getMonth() - 3) //近三个月
        this.startDateBtn = common.getTimeMmss(temDate)
        this.endDateBtn = common.getNowTime()
        break
      case '6':
        this.btnGroupActiveText = '近半年'
        temDate.setMonth(temDate.getMonth() - 6) //近半年
        this.startDateBtn = common.getTimeMmss(temDate)
        this.endDateBtn = common.getNowTime()
        break
      case '7':
        this.btnGroupActiveText = '全部'
        // temDate.setFullYear(temDate.getFullYear() - 1) //近一年
        this.startDateBtn = '2017-01-01 00:00:00'
        this.endDateBtn = common.getNowTime()
        break
      default: //默认近三个月
        this.btnGroupActive = '5'
        this.btnGroupActiveText = '近三个月'
        temDate.setDate(temDate.getDate() - 90)
        this.startDateBtn = common.getTimeMmss(temDate)
        this.endDateBtn = common.getNowTime()
        break
    }
    this.getDeviceInfoData()
    this.getTableDataTab(this.activeTab)
  }
  getTabData(type) {
    this.tableDataTab1 = []
    this.tableDataTab2 = []
    this.tableDataTab2_1 = []
    this.tableDataTab3 = []
    this.tableDataTab3 = []
    this.tableDataTab4_1 = []
    this.tableDataTab4_2 = []
    this.tableDataTab5 = []
    this.tableDataTab6 = []
    this.tableDataTab7.length = 0
    this.totalCountTab = 0
    this.pageSizeTab = 10
    this.curPageTab = 1
    this.activeTab = type
    this.getTableDataTab(type)
  }
  //获取数据:故障信息/维修信息/警报信息/数据修复/固件升级/系数设置
  versionUpdataCount: number
  coefUpdataCount: number
  fix: any = {
    totalCount: 0,
    mainCount: 0,
    sensorCount: 0,
    lineCount: 0,
    gpsCount: 0,
    mainQuestion: 0,
    sensorQuestion: 0,
    lineQuestion: 0,
    gpsQuestion: 0,
    firstFixQuestion: '',
    firstFixQuestionTime: '',
    firstSensorQuestion: '',
    firstSensorQuestionTime: '',
    lastSensorQuestion: '',
    lastSensorQuestionTime: '',
    lastGPSQuestion: '',
    lastGPSQuestionTime: ''
  }
  timelineDate: any = []
  getTableDataTab(type) {
    let reqData: any, param: any
    switch (type) {
      case '':
        this.getDeviceInfoData()
        break
      case '1':
        reqData = {
          pageSize: this.pageSizeTab,
          nowPage: this.curPageTab,
          parameters: {
            deviceId: this.selected[0].deviceId,
            carNumber: this.selectRowData.carNumber,
            startDate: this.startDateBtn,
            endDate: this.endDateBtn
          }
        }
        param = 'gridPager=' + JSON.stringify(reqData)
        this.jsonApiService.http('dataExceptionRecord/dataRecordPage.html', param).subscribe(result => {
          if (!result.isSuccess) {
            this.jsonApiService.message(result.message)
            return
          }
          for (let item of result.exhibitDatas) {
            item.useTypeL1 = this.getUseTypeNameL1(item.useTypeL1)
            item.useTypeL2 = this.getUseTypeNameL2(item.useTypeL2)
            item.exceptionType = this.getExceptionTypeName(item.exceptionType)
            item.programType = this.getProgramTypeName(item.programType)
            if (item.coefficient) {
              let coefArr = []
              for (let i = 0; i < item.coefficient.length; i++) {
                let _item = item.coefficient[i]
                if (_item && _item != '0') {
                  var obj = {
                    value: item.coefficient[i],
                    index: i + 1
                  }
                  coefArr.push(obj)
                }
              }
              item.coef = coefArr
            } else {
              item.coef = []
            }
          }
          this.tableDataTab1 = result.exhibitDatas
          this.totalCountTab = result.recordCount
        })
        break
      case '2':
        reqData = {
          pageSize: this.pageSizeTab,
          nowPage: this.curPageTab,
          parameters: {
            searchKey: this.selected[0].deviceId,
            startTime: this.startDateBtn,
            endTime: this.endDateBtn
          }
        }
        param = 'gridPager=' + JSON.stringify(reqData)
        this.jsonApiService.http('fixdatalog/logforpage.html', param).subscribe(result => {
          if (!result.isSuccess) {
            this.jsonApiService.message(result.message)
            return
          }
          this.tableDataTab2 = result.exhibitDatas
          this.totalCountTab = result.recordCount
        })
        break
      case '2_1':
        reqData = {
          pageSize: this.pageSizeTab,
          nowPage: this.curPageTab,
          parameters: {
            searchKey: this.selected[0].deviceId,
            startDate: this.startDateBtn,
            endDate: this.endDateBtn,
            status: '0'
          }
        }
        param = 'gridPager=' + JSON.stringify(reqData)
        this.jsonApiService.http('exceptionOrderForHaiLuo/findExceptionOrderList.html', param).subscribe(result => {
          if (!result.isSuccess) {
            this.jsonApiService.message(result.message)
            return
          }
          this.tableDataTab2_1 = result.exhibitDatas
          this.totalCountTab = result.recordCount
        })
        break
      case '3':
        reqData = {
          pageSize: this.pageSizeTab,
          nowPage: this.curPageTab,
          parameters: {
            deviceId: this.selected[0].deviceId,
            startTime: this.startDateBtn,
            endTime: this.endDateBtn
          }
        }
        param = 'gridPager=' + JSON.stringify(reqData)
        this.jsonApiService.http('alertlog/deviceShutDownAlarm.html', param).subscribe(result => {
          if (!result.isSuccess) {
            this.jsonApiService.message(result.message)
            return
          }
          if (type == '3') {
            for (let item of result.exhibitDatas) {
              item.totalSecond = common.secondToDate(item.totalSecond)
            }
          }
          this.tableDataTab3 = result.exhibitDatas
          this.totalCountTab = result.recordCount
        })
        break
      case '4_1':
        reqData = {
          pageSize: this.pageSizeTab,
          nowPage: this.curPageTab,
          parameters: {
            deviceId: this.selected[0].deviceId,
            repairedStatus: '0',
            dateType: '1',
            startDate: this.startDateBtn,
            endDate: this.endDateBtn
          }
        }
        param = 'gridPager=' + JSON.stringify(reqData)
        this.jsonApiService.http('deviceRepaired/findDeviceRepairedList.html', param).subscribe(result => {
          if (!result.isSuccess) {
            this.jsonApiService.message(result.message)
            return
          }
          this.tableDataTab4_1 = result.exhibitDatas || []
          this.tableDataTab4_1.map(item => (item.callDuration = common.secondToDate(item.callDuration)))
          this.totalCountTab = result.recordCount
        })
        break
      case '4_2':
        reqData = {
          pageSize: this.pageSizeTab,
          nowPage: this.curPageTab,
          parameters: {
            deviceId: this.selected[0].deviceId,
            sortType: '2',
            startDate: this.startDateBtn,
            endDate: this.endDateBtn
          }
        }
        param = 'gridPager=' + JSON.stringify(reqData)
        this.jsonApiService.http('deviceRepairedV2/findDeviceRepairedV2List.html', param).subscribe(result => {
          if (!result.isSuccess) {
            this.jsonApiService.message(result.message)
            return
          }
          this.tableDataTab4_2 = result.exhibitDatas || []
          for (let item of this.tableDataTab4_2) {
            var faultPhenomenonList = item.faultPhenomenonList && Array.from(new Set(item.faultPhenomenonList))
            item.faultPhenomenonList = faultPhenomenonList.length > 0 ? faultPhenomenonList.join(',') : ''

            item.repairStatus = false // 维修内容是否有更换主机
            if (item.repairContentList && item.repairContentList.length) {
              item.repairStatus = item.repairContentList.some(ele => ele === '更换主机')
            }

            var repairContentList = item.repairContentList && Array.from(new Set(item.repairContentList))
            item.repairContentList = repairContentList.length > 0 ? repairContentList.join(',') : ''

            var repairSubdivideList = item.repairSubdivideList && Array.from(new Set(item.repairSubdivideList))
            item.repairSubdivideList = repairSubdivideList.length > 0 ? repairSubdivideList.join(',') : ''

            item.useTypeL2 = this.getUseTypeNameL2(item.useTypeL2)
          }
          this.totalCountTab = result.recordCount
          this.repairedDeviceInfo.fixedCount = result.recordCount
        })
        break
      case '5':
        reqData = {
          pageSize: this.pageSizeTab,
          nowPage: this.curPageTab,
          parameters: {
            deviceId: this.selected[0].deviceId,
            startTime: this.startDateBtn,
            endTime: this.endDateBtn
          }
        }
        param = 'gridPager=' + JSON.stringify(reqData)
        this.jsonApiService.http('log/upgrade.html', param).subscribe(result => {
          if (!result.isSuccess) {
            this.jsonApiService.message(result.message)
            return
          }
          this.tableDataTab5 = result.exhibitDatas || []
          this.totalCountTab = result.recordCount
        })
        break
      case '6':
        reqData = {
          pageSize: this.pageSizeTab,
          nowPage: this.curPageTab,
          parameters: {
            deviceId: this.selected[0].deviceId,
            startTime: this.startDateBtn,
            endTime: this.endDateBtn
          }
        }
        param = 'gridPager=' + JSON.stringify(reqData)
        this.jsonApiService.http('deviceCoefLog/deviceCoefLogforpage.html', param).subscribe(result => {
          if (!result.isSuccess) {
            this.jsonApiService.message(result.message)
            return
          }
          for (let item of result.exhibitDatas) {
            if (item.newCoef) {
              let newCoef = []
              for (let i = 0; i < item.newCoef.length; i++) {
                let _item = item.newCoef[i]
                if (_item) {
                  let obj: any = {
                    value: item.newCoef[i],
                    index: i + 1
                  }
                  newCoef.push(obj)
                }
              }
              item.newCoef = newCoef
            } else {
              item.newCoef = []
            }

            if (item.oldCoef) {
              let oldCoef = []
              for (let i = 0; i < item.oldCoef.length; i++) {
                let _item = item.oldCoef[i]
                if (_item) {
                  let obj: any = {
                    value: item.oldCoef[i],
                    index: i + 1
                  }
                  oldCoef.push(obj)
                }
              }
              item.oldCoef = oldCoef
            } else {
              item.oldCoef = []
            }
          }
          this.tableDataTab6 = result.exhibitDatas || []
          this.totalCountTab = result.recordCount
        })
        break
      case '7':
        let reqdata: any = {
          pageSize: this.pageSizeTab,
          nowPage: this.curPageTab,
          parameters: {
            companyId: this.selectedCompanyId,
            carNumber: this.carNumber || this.carNumberWeight.split(' ')[0],
            startTime: this.startDateBtn,
            endTime: this.endDateBtn,
            deviceId: this.selected[0].deviceId
          }
        }
        reqdata = 'gridPager=' + JSON.stringify(reqdata)
        this.jsonApiService.http('weighbridge/list.html', reqdata).subscribe(data => {
          this.tableDataTab7 = data.exhibitDatas
          this.totalCountTab = data.recordCount
        })
        break
      case '8':
        this.addHostAndSensor() //主机和传感器
        // reqData = 'deviceId=' + this.selected[0].deviceId
        // this.jsonApiService.http('eventMonitor/eventDataList.html', reqData).subscribe(data => {
        //   if (data.success && data.data) {
        //     this.coefUpdataCount = 0
        //     this.versionUpdataCount = 0
        //     this.fix = {
        //       totalCount: 0,
        //       mainCount: 0,
        //       sensorCount: 0,
        //       lineCount: 0,
        //       gpsCount: 0,
        //       mainQuestion: 0,
        //       sensorQuestion: 0,
        //       lineQuestion: 0,
        //       gpsQuestion: 0,
        //       firstFixQuestion: '',
        //       firstFixQuestionTime: '',
        //       firstSensorQuestion: '',
        //       firstSensorQuestionTime: '',
        //       lastSensorQuestion: '',
        //       lastSensorQuestionTime: '',
        //       lastGPSQuestion: '',
        //       lastGPSQuestionTime: ''
        //     }
        //     let result = data.data
        //     let sensorObj = {}
        //     for (let item of result) {
        //       item.eventType1 == 4 ? (this.coefUpdataCount += 1) : (this.coefUpdataCount = this.coefUpdataCount)
        //       item.eventType1 == 3
        //         ? (this.versionUpdataCount += 1)
        //         : (this.versionUpdataCount = this.versionUpdataCount)
        //       item.eventType2 != 0 ? (this.fix.totalCount += 1) : (this.fix.totalCount = this.fix.totalCount)
        //       item.eventType2Name == '更换主机' ? (this.fix.mainCount += 1) : (this.fix.mainCount = this.fix.mainCount)
        //       item.eventType2Name == '更换传感器'
        //         ? (this.fix.sensorCount += 1)
        //         : (this.fix.sensorCount = this.fix.sensorCount)
        //       item.eventType2Name == '更换线材' ? (this.fix.lineCount += 1) : (this.fix.lineCount = this.fix.lineCount)
        //       item.eventType2Name == '更换GPS' ? (this.fix.gpsCount += 1) : (this.fix.gpsCount = this.fix.gpsCount)
        //       if (item.eventType2 != 0) {
        //         item.eventType2 == 202
        //           ? (this.fix.firstFixQuestion = null)
        //           : (this.fix.firstFixQuestion = item.eventContent)
        //         this.fix.firstFixQuestionTime = item.eventTime
        //       }
        //       if (item.eventType2 == 202) {
        //         this.fix.firstSensorQuestion = item.eventContent
        //         this.fix.firstSensorQuestionTime = item.eventTime
        //         // 增加传感器问题列表
        //         let arr = item.eventContent.split('-')
        //         if (arr.length > 1) {
        //           // 切分出管道号
        //           let channel = arr[arr.length - 1]
        //           item.text1 = '第一次维修CH' + channel
        //           item.text2 = '第一次维修CH' + channel + '时间'
        //           if (sensorObj[channel]) {
        //             // 同一管道只保留最新的数据
        //             let oldTime = sensorObj[channel].eventTime.replace(/-/g, '/')
        //             let newTime = item.eventTime.replace(/-/g, '/')
        //             if (new Date(oldTime).valueOf() > new Date(newTime).valueOf()) {
        //               sensorObj[channel] = item
        //             }
        //           } else {
        //             sensorObj[channel] = item
        //           }
        //         }
        //       }
        //       if (item.eventType2 == 202 && !this.fix.lastSensorQuestion) {
        //         this.fix.lastSensorQuestion = item.eventContent
        //         this.fix.lastSensorQuestionTime = item.eventTime
        //       }
        //       if (item.eventType2 == 204 && !this.fix.lastGPSQuestion) {
        //         this.fix.lastGPSQuestion = item.eventContent
        //         this.fix.lastGPSQuestionTime = item.eventTime
        //       }
        //     }
        //     // 传感器对象进行排序并变成数组的格式
        //     let sensorArr = Object.keys(sensorObj).reduce(function (arr: any, k) {
        //       arr.push(sensorObj[k])
        //       return arr
        //     }, [])
        //     // 给页面的变量赋值
        //     this.sensorList = sensorArr.sort(function (a, b) {
        //       let oldTime = a.eventTime.replace(/-/g, '/')
        //       let newTime = b.eventTime.replace(/-/g, '/')
        //       if (new Date(oldTime).valueOf() < new Date(newTime).valueOf()) {
        //         return -1
        //       }
        //     })

        //     var year = new Date().getFullYear()
        //     let obj: any
        //     this.timelineDate = []
        //     for (let i = 2015; i < year + 1; i++) {
        //       let chrildArr: any = []
        //       obj = null
        //       for (let item of result) {
        //         if (item.eventYear == i) {
        //           chrildArr.push(item)
        //           obj = {
        //             date: item.eventYear + '',
        //             chrild: chrildArr,
        //             isShow: true
        //           }
        //         }
        //       }
        //       if (obj) {
        //         this.timelineDate.push(obj)
        //       }
        //     }
        //     this.timelineDate = this.timelineDate.reverse()
        if (this.deviceBaseInfo.inputDate) {
          this.deviceBaseInfo.installTime = common.secondToDate(
            (common.mmsstoTimestamp(common.getNowTime()) - common.mmsstoTimestamp(this.deviceBaseInfo.inputDate)) /
            1000
          )
        }
        // 获取其他的数据接口
        this.jsonApiService
          .http_obj('system/getRealTimeData.html', { deviceId: this.selected[0].deviceId })
          .subscribe(data => {
            this.otherData = data.data
          })
        //   }
        // })
        break
      default:
        this.getDeviceInfoData()
        break
    }
  }
  /**
   * 设备事件 新增主机生命周期和传感器生命周期
   */
  hostTableData: any = [] //主机table列表
  sensorListData: any = [] //传感器table列表
  sensorCount: string = '' //传感器数量
  addHostAndSensor() {
    this.jsonApiService.http_get('matterReplaceInfo/queryMatterReplaceInfoListByDeviceId.html?deviceId=' + this.selected[0].deviceId).subscribe(data => {
      if (data.success && data.data) {
        let result = data.data
        this.hostTableData = result.hostList || []
        this.sensorListData = result.sensorList ? this.mergeData(result.sensorList, "materielNumber") : []
        this.sensorCount = result.sensorCount
      }
    })
  }
  mergeData(data, indexName) {
    if (data == undefined || data.length == 0 || data == null) {
      return;
    }
    let res = [] //结果数组
    let rowSpan = 1
    for (let i = 0; i < data.length; i++) {
      for (let j = i + 1; j < data.length; j++) {
        if (data[i][indexName] == data[j][indexName]) {
          rowSpan++;
        } else {
          break;
        }
      }
      //开始复制某组相同的数据
      if (rowSpan > 1) {
        for (let k = 0; k < rowSpan; k++) {
          data[k + i].secondIndex = k;
          data[k + i].rowSpan = rowSpan;
          res.push(data[k + i])
        }
        i += (rowSpan - 1) //跳过相同的数据
        rowSpan = 1;
      } else {
        //复制单独的数据
        data[i].secondIndex = 0;
        data[i].rowSpan = rowSpan;
        res.push(data[i])
      }
    }
    return res
  }
  getDeviceInfoData() {
    this.initDeviceBaseInfo()
    //设备基本信息
    this.jsonApiService
      .http_obj('system/getDeviceBaseInfoByDeviceId.html', { deviceId: this.selected[0].deviceId })
      .subscribe(data => {
        if (data.success && data.data) {
          for (let item in this.deviceBaseInfo) {
            if (item === 'coef' || item === 'coefT' || item === 'sensorChannel') {
              this.deviceBaseInfo[item] = data.data[item] || []
            } else {
              this.deviceBaseInfo[item] = data.data[item] || ''
            }
          }
          this.deviceBaseInfo.userTypeName = this.getUseTypeNameL2(this.deviceBaseInfo.useTypeL2)
          if (this.deviceBaseInfo.coef) {
            let coefArr = []
            for (let i = 0; i < this.deviceBaseInfo.coef.length; i++) {
              let _item = this.deviceBaseInfo.coef[i]
              if (_item) {
                let obj: any = {
                  value: _item,
                  index: i + 1
                }
                coefArr.push(obj)
              }
            }
            this.deviceBaseInfo.coefT = coefArr
          } else {
            this.deviceBaseInfo.coefT = []
          }
        }
      })
    //问题统计(近三个月)
    this.jsonApiService
      .http_obj('system/countDeviceDataRecordByDeviceId.html', {
        deviceId: this.selected[0].deviceId,
        startDate: this.startDateBtn,
        endDate: this.endDateBtn
      })
      .subscribe(data => {
        if (data.success && data.data) {
          this.questionRecordTotal = 0
          this.questionRecordInfo = data.data
          for (let item of this.questionRecordInfo) {
            this.questionRecordTotal += +item.reasonCount
          }
        }
      })
    //数据修复统计(近三个月)
    this.jsonApiService
      .http_obj('system/queryDataFixCountByDeviceId.html', {
        deviceId: this.selected[0].deviceId,
        startDate: this.startDateBtn,
        endDate: this.endDateBtn
      })
      .subscribe(data => {
        if (data.success && data.data) {
          this.dataFixInfo = data.data
        }
      })
    //警报统计(近三个月)load
    this.jsonApiService
      .http_obj('system/queryAlarmCountByDeviceId.html', {
        deviceId: this.selected[0].deviceId,
        startDate: this.startDateBtn,
        endDate: this.endDateBtn
      })
      .subscribe(data => {
        if (data.success && data.data) {
          this.alertDataInfo = data.data
        }
      })
    //维修记录统计(近三个月)
    this.jsonApiService
      .http_obj('system/queryDeviceRepairedByDeviceId.html', {
        deviceId: this.selected[0].deviceId,
        startDate: this.startDateBtn,
        endDate: this.endDateBtn
      })
      .subscribe(data => {
        if (data.success && data.data) {
          this.repairedDeviceInfo = data.data
        }
      })
    //设备状态(实时数据)
    let deviceId = this.selected[0].deviceId
    this.jsonApiService
      .http_obj('system/getRealTimeData.html', { deviceId: this.selected[0].deviceId })
      .subscribe(data => {
        if (data.success && data.data) {
          this.deviceRealTimeDataInfo = data.data
          let carUploadDate, gpsUploadDate
          if (this.deviceRealTimeDataInfo.carUploadDate) {
            carUploadDate = this.deviceRealTimeDataInfo.carUploadDate
          }
          if (this.deviceRealTimeDataInfo.gpsUploadDate) {
            gpsUploadDate = this.deviceRealTimeDataInfo.gpsUploadDate
          }
          if (gpsUploadDate && carUploadDate) {
            let abs = Math.abs(common.mmsstoTimestamp(carUploadDate) - common.mmsstoTimestamp(gpsUploadDate))
            abs >= 30 * 60 * 1000 ? (this.isShowGPSAlert = true) : (this.isShowGPSAlert = false) //计算GPS是否异常:更新时间 - gps更新时间  > 30分钟    =>GPS异常
            this.getWeighbridge(deviceId)
          }
        }
      })
    // 总磅单数（近三个月）
    const reqDate = {
      deviceId: this.selected[0].deviceId,
      startDate: this.startDateBtn,
      endDate: this.endDateBtn
    }
    this.jsonApiService.http_obj('system/queryWeightBridgeByDeviceId.html', reqDate).subscribe(result => {
      if (result.success) {
        this.weightData = result.data
      }
    })
  }
  //根据编码映射对应车辆类型名称
  getUseTypeNameL1(key) {
    if (key) {
      return this.TcarUseList[key]
    } else {
      return ''
    }
  }
  //问题分类
  getExceptionTypeName(key) {
    if (key) {
      return this.questionNameList[key]
    } else {
      return ''
    }
  }
  //现象分类
  getProgramTypeName(key) {
    if (key) {
      return this.questionDeatailNameList[key]
    } else {
      return ''
    }
  }
  questionNameList: any = {
    '1': '算法问题',
    '2': '硬件问题',
    '3': '司机问题',
    '4': '对接问题',
    '5': '运维问题',
    '6': '安装问题'
  }
  questionDeatailNameList: any = {
    '100': '其他',
    '101': '上货问题',
    '102': '卸货问题',
    '103': '在途问题',
    '104': '多次上货',
    '105': '多次卸货',
    '200': '其他',
    '201': '主机问题',
    '202': '传感器问题',
    '203': 'GPS问题',
    '204': '线材问题',
    '300': '其他',
    '301': '司机问题',
    '400': '其他',
    '401': '对接问题',
    '500': '其他',
    '501': '运维问题',
    '601': '安装问题',
    '600': '其他'
  }
  carNumberWeight: string = '' //地磅数据车辆车牌
  sensorList: any = [] // 设备事件模块中的传感器通道问题数组
  otherData: any = {} // 设备事件模块中的其他数据 弥补之前的接口数据不足
  //获取磅单数据:用于判断离线异常
  getWeighbridge(deviceId) {
    this.jsonApiService
      .http_obj('weighbridge/weightforreal.html', {
        deviceId: deviceId,
        startTime: this.deviceRealTimeDataInfo.updateTime,
        endTime: common.getNowTime()
      })
      .subscribe(data => {
        if (data.success && data.data) {
          this.weightCount = 0
          if (this.deviceRealTimeDataInfo.updateTime) {
            let diffTiem =
              common.mmsstoTimestamp(common.getNowTime()) -
              common.mmsstoTimestamp(this.deviceRealTimeDataInfo.updateTime)
            this.offlineDiffTime = common.secondToDate(diffTiem / 1000) //计算离线时长:当前时间 - 最后更新时间
            let weightData = data.data
            for (let item of weightData) {
              if (+item.weight > 0) {
                this.isShowOfflineAlert = true
                this.weightCount += 1 //计算榜单数
              }
            }
          }
        }
      })
  }
  refreshTab() {
    this.getTabData(this.activeTab)
  }
  //分页回调
  paginateTab(e) {
    this.curPageTab = e.page + 1
    this.pageSizeTab = e.rows
    this.getTableDataTab(this.activeTab)
  }
  /**
   * 问题记录跳转
   */
  jumpQuestionByHand(type1, type2, value) {
    if (value == 'total') {
      $('#myTab').find('li.s-lis').removeClass('active')
      $('#all').removeClass('active')
      $('#myTab').find('li.s-lis').find('.reqRecord').parent('li.s-lis').addClass('active')
      $('#question').addClass('active')
      this.getTabData('1')
      return false
    }

    if (value == 0) {
      this.jsonApiService.message('无记录!')
      return
    }
    $('#deviceDetailModal').hide()
    let queryParams = {
      companyName: this.selectRowData.companyName,
      companyId: this.selectRowData.companyId,
      deviceId: this.selectRowData.deviceId,
      carNumber: this.selectRowData.carNumber,
      startTime: this.startDateBtn,
      endTime: this.endDateBtn,
      exceptionType: type1,
      programType: type2
    }
    this.router.navigate(['/abnormal-alert/artificialMonitor'])
    common.setCookie('jumpQuestionByHandList', JSON.stringify(queryParams))
    setTimeout(function () {
      $('#left-panel').find('.top-menu-invisible.open').find('.UL').css('display', 'none')
      $('#left-panel').find('.top-menu-invisible.open').removeClass('open')
      $('#left-panel').find('.top-menu-invisible.active').addClass('open')
      $('#left-panel').find('.top-menu-invisible.active').find('.UL').css('display', 'block')
    }, 350)
  }
  /**
   * 设备警报跳转
   */
  jumpAlertDataList(type, value) {
    if (value == 'total') {
      this.getTabData('3')
      $('#myTab').find('li.s-lis').removeClass('active').find('.alertRecord').parent('li.s-lis').addClass('active')
      $('#all').removeClass('active')
      $('#alert').addClass('active')
      return false
    }

    if (!value) {
      this.jsonApiService.message('无记录!')
      return
    }
    $('#deviceDetailModal').hide()
    let queryParams = {
      companyName: this.selectRowData.companyName,
      companyId: this.selectRowData.companyId,
      deviceId: this.selectRowData.deviceId,
      carNumber: this.selectRowData.carNumber,
      startTime: this.startDateBtn,
      endTime: this.endDateBtn,
      type: type
    }
    this.router.navigate(['/abnormal-alert/device-off'])
    common.setCookie('jumpAlertDataList', JSON.stringify(queryParams))
    setTimeout(function () {
      $('#left-panel').find('.top-menu-invisible.open').find('.UL').css('display', 'none')
      $('#left-panel').find('.top-menu-invisible.open').removeClass('open')
      $('#left-panel').find('.top-menu-invisible.active').addClass('open')
      $('#left-panel').find('.top-menu-invisible.active').find('.UL').css('display', 'block')
    }, 350)
  }
  /**
   * 设备维修跳转
   */
  jumpRepairedDeviceList(type, dateType, value) {
    if (!value) {
      this.jsonApiService.message('无记录!')
      return
    }
    $('#deviceDetailModal').hide()
    let queryParams = {
      companyName: this.selectRowData.companyName,
      companyId: this.selectRowData.companyId,
      deviceId: this.selectRowData.deviceId,
      carNumber: this.selectRowData.carNumber,
      startTime: this.startDateBtn,
      endTime: this.endDateBtn,
      repairedStatus: type,
      dateType: dateType
    }
    if (type == '0') {
      this.router.navigate(['/device-management/fault'])
    } else if (type == '1') {
      this.router.navigateByUrl('/system/blank').then(() => {
        this.router.navigate(['/device-management/faultV2'])
      })
    }
    common.setCookie('jumpRepairedDeviceList', JSON.stringify(queryParams))
    setTimeout(function () {
      $('#left-panel').find('.top-menu-invisible.open').find('.UL').css('display', 'none')
      $('#left-panel').find('.top-menu-invisible.open').removeClass('open')
      $('#left-panel').find('.top-menu-invisible.active').addClass('open')
      $('#left-panel').find('.top-menu-invisible.active').find('.UL').css('display', 'block')
    }, 350)
  }
  jumpDataFixList(type, value) {
    if (!value) {
      this.jsonApiService.message('无记录!')
      return
    }
    $('#deviceDetailModal').hide()
    let queryParams = {
      companyName: this.selectRowData.companyName,
      companyId: this.selectRowData.companyId,
      deviceId: this.selectRowData.deviceId,
      carNumber: this.selectRowData.carNumber,
      startTime: this.startDateBtn,
      endTime: this.endDateBtn,
      type: null
    }
    switch (type) {
      case '1':
        queryParams.type = '1'
        this.router.navigate(['/log-info/repairRecord'])
        common.setCookie('jumpDataFixList', JSON.stringify(queryParams))
        break
      case '2':
        queryParams.type = '2'
        this.router.navigate(['/log-info/repairRecord'])
        common.setCookie('jumpDataFixList', JSON.stringify(queryParams))
        break
      case '3':
        queryParams.type = '0'
        this.router.navigate(['/abnormal-alert/order'])
        common.setCookie('jumpExceptionOrderList', JSON.stringify(queryParams))
        break
      default:
        break
    }
    setTimeout(function () {
      $('#left-panel').find('.top-menu-invisible.open').find('.UL').css('display', 'none')
      $('#left-panel').find('.top-menu-invisible.open').removeClass('open')
      $('#left-panel').find('.top-menu-invisible.active').addClass('open')
      $('#left-panel').find('.top-menu-invisible.active').find('.UL').css('display', 'block')
    }, 350)
  }

  /* 新增

        不良记录

    */
  //新增 操作
  recordDetailFrom: any = {
    id: '',
    returnTime: '',
    carNumber: '',
    companyName: '',
    deviceId: '',
    productNo: '',
    productTime: '',
    hwVersion: '',
    badReasons: '',
    improvementStrategy: '',
    resolutionTime: '',
    principal: '',
    imagePaths: '',
    faultPhenomenon: '',
    repairedId: '',
    repairSubdivideStr: '',
    zhiJuId: '',
    iccid: '',
    retestResult: '', //复测结果
    retestRemark: '' //复测结果备注
  }
  imageInfoList: any = []
  addRecordDetail(modal) {
    for (let key in this.recordDetailFrom) {
      this.recordDetailFrom[key] = ''
    }
    this.fixtureSublist = []; //治具检测清空
    this.repairedSublist = []; //已维修选中列表清空
    this.recordDetailFrom.repairedId = ''
    this.recordDetailFrom.zhiJuId = ''
    this.recordDetailFrom.returnTime = common.getTimeMmss(new Date())
    this.imageInfoList = []
    if (this.selected.length == 0) {
      this.jsonApiService.message('请先选择一条记录来新增')
      return
    }
    if (this.selected.length != 1) {
      this.jsonApiService.message('只能选择一条[已维修]记录来新增')
      return
    }
    //      if(this.selected[0].repairedStatus != 1){
    //          this.jsonApiService.message('只能选择一条[已维修]记录来新增');
    //          return
    //      }
    this.recordDetailFrom.carNumber = this.selected[0].carNumber
    this.recordDetailFrom.deviceId = this.selected[0].deviceId
    this.recordDetailFrom.companyName = this.selected[0].companyName
    this.recordDetailFrom.repairedId = this.selected[0].id
    this.jsonApiService
      .http_get(
        'deviceRepaired/getHostBaseInfo.html?deviceId=' +
        this.selected[0].deviceId +
        '&repairedId=' +
        this.selected[0].id +
        '&isConnectRepaired=1'
      )
      .subscribe(data => {
        if (data.success) {
          this.recordDetailFrom.productNo = data.data.productNo
          this.recordDetailFrom.productTime = data.data.productTime
          this.recordDetailFrom.hwVersion = data.data.hwVersion
          this.recordDetailFrom.faultPhenomenon = data.data.faultPhenomenonStr
          this.recordDetailFrom.iccid = data.data.iccid
          if (data.data.repairedId) {
            let obj = {
              carNumber: data.data.carNumber,
              companyId: data.data.companyId,
              companyName: data.data.companyName,
              deviceId: data.data.deviceId,
              faultPhenomenonList: data.data.faultPhenomenon,
              id: data.data.repairedId,
              repairSubdivideList: data.data.repairedSubdivide,
              repairedTime: data.data.repairedTime,
              repairedType: data.data.repairedType,
              repairedUserName: data.data.repairedUser,
              warrantyExpirationTime: data.data.warrantyExpirationTime,
              expire: data.data.expire
            }
            this.repairedSublist.push(obj)
          }
          if (data.data.zhiJuId) {
            let obj = {
              checkMen: data.data.checkMen,
              checkTime: data.data.checkTime,
              zhiJuResult: data.data.zhiJuResult
            }
            this.recordDetailFrom.zhiJuId = data.data.zhiJuId
            this.fixtureSublist.push(obj)
          }
        } else {
          this.jsonApiService.message(data.message)
        }
        modal.show()
      })
  }
  recordDetailClose(modal) {
    for (let key in this.recordDetailFrom) {
      this.recordDetailFrom[key] = ''
    }
    modal.hide()
  }
  recordDetailSubmit(modal) {
    if (!this.recordDetailFrom.returnTime) {
      this.jsonApiService.message('寄回时间不能为空')
      return
    }
    if (!this.recordDetailFrom.deviceId) {
      this.jsonApiService.message('设备ID不能为空')
      return
    }
    if (!this.recordDetailFrom.retestResult) {
      this.jsonApiService.message('复测结果不能为空')
      return
    }
    if (!this.recordDetailFrom.faultPhenomenon) {
      this.jsonApiService.message('复测故障现象不能为空')
      return
    }
    this.recordDetailFrom.returnTime = $('#returnTime').val()
    this.recordDetailFrom.productTime = $('#productTime').val()
    this.recordDetailFrom.resolutionTime = $('#resolutionTime').val()
    this.recordDetailFrom.imagePaths = this.imageInfoList.join(',')
    let reqdata = JSON.parse(JSON.stringify(this.recordDetailFrom))
    this.jsonApiService.http_obj('deviceRepaired/add.html', reqdata).subscribe(data => {
      this.jsonApiService.message(data.message)
      if (data.success) {
        this.load()
        modal.hide()
      }
    })
  }

  fileList: File = null
  //上传多张
  multifileChange(files: FileList) {
    if (this.isViewer2 && $('.viewer-container').length > 0) {
      this.viewer.destroy()
    }

    var that = this
    let multfileList = files

    var reqdata = new FormData()
    reqdata.append('describe', '不良记录')
    reqdata.append('businessType', '1')
    // reqdata.append('deviceId', this.page.deviceId);
    reqdata.append('type', '2') //type 1获取相对路径  2获取绝对路径

    for (var i = 0; i < multfileList.length; i++) {
      this.fileList = multfileList[i]
      const isJPG =
        this.fileList.type === 'image/jpeg' || this.fileList.type === 'image/jpg' || this.fileList.type === 'image/png'
      if (!isJPG) {
        this.jsonApiService.message('上传图片只能是 png, jpg, jpeg 格式!')
        return
      }

      reqdata.append('files', multfileList[i])
    }

    that.jsonApiService.form_http('fileUpload/upload.html', reqdata).subscribe(data => {
      if (data.success) {
        for (var i = 0; i < data.data.length; i++) {
          that.imageInfoList.push(data.data[i])
        }
      }
    })

    for (let k = 0; k < $('.up').length; k++) {
      $('.up')[k].value = null
    }
  }
  //删除
  deleteImg(i) {
    this.imageInfoList.splice(i, 1)

    if (this.isViewer2 && $('.viewer-container').length > 0) {
      this.viewer.destroy()
    }
  }
  bigImg2: any = '' //
  isViewer2: boolean = false //默认隐藏
  bigImgClick(modal, img) {
    // modal.show();
    this.bigImg2 = img
    if (this.isViewer2 && $('.viewer-container').length > 0) {
      System.import('assets/js/viewer/viewer.js').then(() => {
        System.import('assets/js/viewer/bootstrap.bundle.min.js').then(() => {
          System.import('assets/js/viewer/viewer.css').then(() => {
            this.showImg2()
          })
        })
      })
    } else {
      this.showImg2()
    }
  }
  //显示图片组件
  viewer2: any = ''
  showImg2() {
    var that = this
    var imgList = $('.imgFileList')[0]
    this.viewer2 = new Viewer(imgList, {
      url: 'src',
      title: function (image) {
        return image.alt + ' (' + (this.index + 1) + '/' + this.length + ')'
      }
    })
    that.isViewer2 = true
  }

  /**
     * 治具弹窗
     */
  fixtureListData: any = [] //治具弹窗列表数据
  fixtureSelected: any = []; //治具勾选数据
  fixtureSublist: any = [] //提交的治具数据
  repairedSublist: any = [] //确定提交的维修数据
  //新增治具列表弹窗
  addFixtureRecord(modal) {
    if (!this.recordDetailFrom.deviceId) {
      this.jsonApiService.message("请选择车牌或输入设备ID");
      return;
    } else {
      modal.show()
      this.jsonApiService.http_obj("deviceRepaired/getZhiJuLogDataByDeviceId.html", { 'deviceId': this.recordDetailFrom.deviceId, 'repairedId': this.recordDetailFrom.repairedId }).subscribe(result => {
        this.fixtureSelected = []
        this.fixtureListData = result.data;
        for (let item of this.fixtureListData) {
          if (item.zhiJuId === this.recordDetailFrom.zhiJuId) {
            item['isChecked'] = true;
            this.fixtureSelected.push(item)
          } else {
            item['isChecked'] = false;
          }
        }
      });
    }
  }
  //table复选框数据row选中事件回调:处理选中状态和deviceId
  rowFixtureSelected(row, e, index) {
    if (row.isChecked) {
      row.isChecked = false;
      this.fixtureSelected.forEach((el, i) => {
        if (el.zhiJuId === row.zhiJuId) {
          this.fixtureSelected.splice(i, 1);
        }
      })
    } else {
      row.isChecked = true;
      this.fixtureSelected.push(row);
    }
  }
  //关闭治具弹窗
  fixtureModalClose(modal) {
    modal.hide()
  }
  //提交治具弹窗
  fixtureModalSubmit(modal) {
    if (this.fixtureSelected.length == 0) {
      this.jsonApiService.message("请勾选至少一条数据");
      return;
    }
    if (this.fixtureSelected.length > 1) {
      this.jsonApiService.message("请选择一条数据添加,暂不支持多条数据添加");
      return;
    }
    this.fixtureSublist = JSON.parse(JSON.stringify(this.fixtureSelected))
    this.recordDetailFrom.zhiJuId = this.fixtureSelected[0].zhiJuId;
    this.fixtureModalClose(modal);
  }
  //点击维修未关联
  notFixtureRecord(modal1) {
    this.recordDetailFrom.zhiJuId = ''
    this.fixtureSublist = []
    modal1.hide()
  }

  /**
   * 待维修的删除
   */
  deleteRepaireRow(row) {
    this.jsonApiService.confirm_message('此操作将永久删除数据,确认要删除?').then(() => {
      var reqdata = 'id=' + row.id
      this.jsonApiService.http('deviceRepaired/delDeviceRepairedById.html', reqdata).subscribe(result => {
        this.jsonApiService.message(result.message)
        this.getTabData('4_1')
      })
    })
  }

  /**
   *
   * 维修对账统计导出
   *
   */
  recordPopupCompany: any = [] //初始化公司的数据
  threeStateText: boolean = false
  inputApi: string = 'company/getParentCompany.html'
  recordPopupOptions = {
    excluded: [':disabled'],
    feedbackIcons: {
      valid: 'glyphicon glyphicon-ok',
      invalid: 'glyphicon glyphicon-remove',
      validating: 'glyphicon glyphicon-refresh'
    },
    fields: {
      recordCompanyName: {
        trigger: 'change',
        validators: {
          notEmpty: {
            message: '请选择所选厂区'
          }
        }
      },
      startRecordTime: {
        trigger: 'change',
        validators: {
          notEmpty: {
            message: '请选择开始时间'
          }
        }
      },
      endRecordTime: {
        trigger: 'change',
        validators: {
          notEmpty: {
            message: '请选择结束时间'
          }
        }
      }
    }
  }
  //点击对接厂区
  companySelectedClick() {
    $('#recordPopupCompany .s_tree_box.s_tree_box_width').addClass('tree_open')
  }
  //初始化日期
  initRecordDate() {
    System.import('assets/js/datepicker/js/bootstrap-datetimepicker.min.js').then(() => {
      System.import('assets/js/datepicker/locales/bootstrap-datetimepicker.zh-CN.js').then(() => {
        common.initDatePicker('#auditorTime', 0)
        $('#startRecordTime')
          .datetimepicker({
            //时间插件
            format: 'yyyy-mm-dd hh:ii:ss',
            language: 'zh-CN',
            autoclose: true
          })
          .on('changeDate', function (e) {
            var date = e.date
            if (!date) {
              return
            }
            var time = common.getTimeMmss(date)
            $('#endRecordTime').datetimepicker('setStartDate', time)
          })
        $('#endRecordTime')
          .datetimepicker({
            //时间插件
            format: 'yyyy-mm-dd hh:ii:ss',
            language: 'zh-CN',
            autoclose: true
          })
          .on('changeDate', function (e) {
            var date = e.date
            if (!date) {
              return
            }
            var time = common.getTimeMmss(date)
            $('#startRecordTime').datetimepicker('setEndDate', time)
          })
      })
    })
  }
  recordPopupForm: any = {
    companyArrays: [],
    allCompanyId: '',
    startTime: '',
    endTime: '',
    type: 1 //1服务费
  }
  dataRecordPopup(modal) {
    this.closePopupModal(modal)
    modal.show()
  }
  closePopupModal(modal) {
    $('#recordPopupForm').data('bootstrapValidator').resetForm()
    this.recordPopupForm.companyArrays = []
    this.recordPopupForm.allCompanyId = ''
    this.recordPopupForm.startTime = ''
    this.recordPopupForm.endTime = ''
    this.recordPopupForm.type = 1 //1服务费
    $('#startRecordTime').val('')
    $('#endRecordTime').val('')
    $('#endRecordTime').datetimepicker('setStartDate', null)
    $('#startRecordTime').datetimepicker('setEndDate', null)
    modal.hide()
  }

  addRecordCompanySelected(data) {
    if (data.companyIdSelectedList.length > 0) {
      this.recordPopupForm.allCompanyId = data.companyIdSelectedList.join(',')
    }
  }
  submitPopupModal(modal, modal2) {
    $('#recordPopupForm').bootstrapValidator('validate') //开启验证
    let isValid = $('#recordPopupForm').data('bootstrapValidator').isValid() //验证是否通过
    if (isValid) {
      this.recordPopupForm.startTime = $('#startRecordTime').val()
      this.recordPopupForm.endTime = $('#endRecordTime').val()
      const reqValue = {
        parameters: {
          startTime: this.recordPopupForm.startTime,
          endTime: this.recordPopupForm.endTime,
          companyId: this.recordPopupForm.allCompanyId,
          type: 0
        }
      }
      let reqdata = 'gridPager=' + JSON.stringify(reqValue)
      // let reqdata = 'startTime=' + this.recordPopupForm.startTime + '&endTime=' + this.recordPopupForm.endTime + '&companyId=' + this.recordPopupForm.allCompanyId + '&type=0';
      this.jsonApiService.http('deviceRepairedV2/totalDeviceRepairedData.html', reqdata).subscribe(result => {
        if (result && result.success) {
          modal.hide()
          this.submitCheckTableData = JSON.parse(JSON.stringify(result.data))
          modal2.show()
        } else {
          this.jsonApiService.message(result.message)
        }
      })
    }
  }

  /**
   * 维修对账统计核对
   */
  submitCheckTableData: any = [] //核对列表
  //关闭
  cancelSubmitCheck(modal2, modal1) {
    this.submitCheckTableData = []
    modal2.hide()
    modal1.show()
  }
  //提交
  submitCheck(modal) {
    if (this.submitCheckTableData.length == 0) {
      this.jsonApiService.message('暂无需要提交核对的数据')
      return
    }

    let reqdata = {
      parameters: {
        startTime: this.recordPopupForm.startTime,
        endTime: this.recordPopupForm.endTime,
        companyId: this.recordPopupForm.allCompanyId,
        type: 1
      }
    }

    modal.hide()
    common.exprotDataFile(reqdata, 'gridPager', config.BaseURL + 'deviceRepairedV2/totalDeviceRepairedData.html')
  }

  // 主机维修统计导出
  hostExportData() {
    // 导出的
    this.startTime = $('#datetimepicker3').val()
    this.endTime = $('#datetimepicker4').val()
    if (!this.startTime || !this.endTime) {
      this.jsonApiService.message('请先选择时间')
      return
    }
    window.location.href =
      config.BaseURL +
      'deviceRepairedV2/statisticsHostFix.html?startTime=' +
      this.startTime +
      '&endTime=' +
      this.endTime
  }

  // 绑定快递单号
  driverTake: number = 0
  expressDeliveryNumber: string = ''
  returnedRepairedImage: string = ''
  selectRowId: string = ''
  openBindingExpress(row, modal) {
    this.selectRowId = row.id
    this.driverTake = row.expressDeliveryNumber === '司机带走主机' ? 1 : 0
    this.expressDeliveryNumber = row.expressDeliveryNumber && row.expressDeliveryNumber !== '司机带走主机' ? row.expressDeliveryNumber : ''
    this.returnedRepairedImage  = row.returnedRepairedImage ? row.returnedRepairedImage : ''
    modal.show()
  }
  bindingExpressClose(modal) {
    this.expressDeliveryNumber = ''
    modal.hide()
  }
  bindingExpressSubmit(modal) {
    if (this.driverTake=== 0 && !this.expressDeliveryNumber) {
      this.jsonApiService.message('请输入快递单号')
      return
    }
    this.jsonApiService
      .http_obj('deviceRepairedV2/addEditCourierNumber.html', {
        id: this.selectRowId,
        driverTake: this.driverTake,
        expressDeliveryNumber: this.expressDeliveryNumber
      })
      .subscribe(result => {
        this.load()
        modal.hide()
        this.jsonApiService.message(result.message)
      })
  }

  //图片放大
  bigImg3() {
    // modal.show();
    if (this.isViewer && $('.viewer-container').length > 0) {
      System.import('assets/js/viewer/viewer.js').then(() => {
        System.import('assets/js/viewer/bootstrap.bundle.min.js').then(() => {
          System.import('assets/js/viewer/viewer.css').then(() => {
            this.showImg3()
          })
        })
      })
    } else {
      this.showImg3()
    }
  }
  showImg3() {
    var that = this
    var imgList = $('.imagesCur')[0]

    this.viewer = new Viewer(imgList, {
      url: 'src',
      title: function (image) {
        return image.alt + ' (' + (this.index + 1) + '/' + this.length + ')'
      }
    })
    that.isViewer = true
  }


  // 查看传感器到期保修时间
  sensorTableData: any[] = []
  seeSensorNumber(row, modal) {
    this.sensorTableData = row.sensorRepairInfoList
    modal.show()
  }
  cancelSensorModal(modal) {
    this.sensorTableData = []
    modal.hide()
  }

  excludeHangProblem = '0' // 是否排除甩挂问题: 传参： 1 是 0 否

  // 打开维修次数导出弹框
  showRepairedTime = modal => {
    this.excludeHangProblem = '0'
    $('#repair1').prop('checked', true) // 设置默认选中否
    modal.show()
  }

  // 关闭维修次数弹框
  countModalClose = modal => {
    modal.hide()
  }

  // 使用 change 事件修改参数
  repairChange = val => {
    this.excludeHangProblem = val
  }

  // 维修次数据统计
  exportRepairedTimeData(modal) {
    const startTime = $('#datetimepicker3').val()
    const endTime = $('#datetimepicker4').val()
    if (!startTime || !endTime) {
      this.jsonApiService.message('请先选择时间')
      return
    }
    if (common.mmsstoTimestamp(startTime) > common.mmsstoTimestamp(endTime)) {
      this.jsonApiService.message('开始时间不能晚于结束时间')
      return
    }
    const data = {
      parameters: {
        sortType: this.sortType,
        searchKey: this.searchKey,
        companyType: this.companyType,
        companyId: this.selectedCompanyId,
        deviceId: this.deviceId,
        userName: this.userName,
        startDate: this.startTime,
        endDate: this.endTime,
        useTypeL2: this.useTypeL2,
        faultPhenomenon: this.faultPhenomenon,
        repairContent: this.repairContent,
        provinceId: this.provinceId,
        expire: this.expire,
        businessType: this.businessType, // 行业类型
        excludeHangProblem: this.excludeHangProblem // 是否排除甩挂问题: 传参： 1是 0否
      }
    }
    console.log('query params', data);
    common.exprotDataFile(data, 'gridPager', config.BaseURL + 'deviceRepairedV2/statisticsRepairedNum.html')
    modal.hide()
  }

}
